My program is running correctly, but this error is being displayed in the compiler. How to fix it?
No answer regarding this can be found on Google, I checked quite many times.
activity_main
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/mainLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<!-- username-->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/username_TIL"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="100dp"
android:elevation="2dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/username_TIET"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/username" />
</com.google.android.material.textfield.TextInputLayout>
<!-- password-->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/password_TIL"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_below="#id/username_TIL">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/password_TIET"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="password"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- confirmPassword-->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/confirmPassword_TIL"
android:layout_width="250dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="20dp"
android:layout_below="#id/password_TIL">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/confirmPassword_TIET"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:hint="#string/confirm_password"/>
</com.google.android.material.textfield.TextInputLayout>
<!-- SignIn-->
<androidx.appcompat.widget.AppCompatButton
android:id="#+id/signIn_BTN"
android:layout_width="100dp"
android:layout_height="wrap_content"
android:text="#string/sign_in"
android:textColor="#android:color/white"
app:cornerRadius="50dp"
android:elevation="2dp"
android:layout_below="#id/confirmPassword_TIL"
android:layout_marginTop="20dp"
android:layout_centerHorizontal="true"
android:background="#android:color/holo_blue_light"/>
</RelativeLayout>
MainActivity has nothing in it - initialised
Manifest File also has nothing extra added to it. Any explanations towards why is this error occurring. Also one more error is being displayed.
E/InputTransport: ro.sf.lcd_density must be defined as a build property
I had the same problem but mine was because of screen density. You may need to revise your images or icons size if any in the drawable folder then generate a copy to following directories.
res/
drawable-xxxhdpi/
example.png
drawable-xxhdpi/
example.png
drawable-xhdpi/
example.png
drawable-hdpi/
example.png
drawable-mdpi/
example.png
For more info read here
To eliminate this error message, add the following line to the build.prop file located in the /system folder on the device:
ro.sf.lcd_density=160
This sets the display density to 160 dpi, which is the lowest among currently supported devices. You can adjust it to match the specific density of your device.
Note: You need to have root access to the device in order to edit the build.prop file. Since this can cause issues on some devices, it is to make a backup of the original file before making any changes.
Related
I am working on new app in which I have to take care of design over mobile devices and tablets.I already read on SO that for this thing I need to create several buckets for sizes to avoid bad look of app on larger or smaller screen at the same time. here is the code I am working on
[![<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
android:layout_width="match_parent"
android:layout_margin="35dp"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/lblLogo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:autoSizeTextType="uniform"
android:gravity="center"
android:padding="15dp"
android:text="My App Name"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textColor="#color/colorPrimaryDark"
android:textSize="32sp" />
<!-- Email Label -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/tilLoginEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/etLoginEmail"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Email"
android:inputType="textEmailAddress" />
</com.google.android.material.textfield.TextInputLayout>
<!-- Password Label -->
<com.google.android.material.textfield.TextInputLayout
android:id="#+id/tilLoginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">
<com.google.android.material.textfield.TextInputEditText
android:id="#+id/etLoginPassword"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Password"
android:inputType="textPassword" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/btnLogin"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="20dp"
android:padding="12dp"
android:text="#string/btnLogin" />
</LinearLayout>
]
This is how the above code looks like on mobile phone (i.e Nexus 6)
**This is how the above code looks like on tablet (i.e Nexus 10)
Notice that on tablet is looking so bad. I know how to handle design in different design buckets. but I want to check if there is any
other solution without replicating the same design file in different
screen sizes buckets
Thanks in advance......
Instead of duplicate the layout try to:
avoid to hardcode the dimension in the layout.
use a ConstraintLayout
use the different qualifiers
For example the margin in your root view:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="#dimen/login_layout_margin"
android:layout_marginEnd="#dimen/login_layout_margin"
android:layout_gravity="center"
android:orientation="vertical">
<TextView
android:id="#+id/lblLogo"
..>
</LinearLayout>
Then create different dimension in different folder:
res/values/dimens.xml:
<dimen name="login_layout_margin">35dp</dimen>
res/values-sw600dp/dimens.xml:
<dimen name="login_layout_margin">350dp</dimen>
More details here.
how could i change brightness 1. click 50% second click 100% 3. click 0% via widget button? i am actuali stack on premission becouse it telling me This Premission is only gatanted to system apps, so is it possible to even do that ?
my target is to add all this to my widget -
<LinearLayout
android:id="#+id/widget_button_layout"
android:layout_width="match_parent"
android:layout_height="53dp"
android:layout_alignParentBottom="true"
android:background="#drawable/widget_buttons_background"
android:orientation="horizontal"
android:weightSum="1">
<ImageButton
android:id="#+id/widget_bluethooth"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:layout_marginEnd="1dp"
android:scaleType="fitXY"
android:background="#drawable/widget_bluethooth_btn" />
<ImageButton
android:id="#+id/widget_settings"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp"
android:scaleType="fitXY"
android:background="#drawable/widget_settings_btn" />
<ImageButton
android:id="#+id/widget_wifi"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:layout_marginStart="1dp"
android:layout_marginEnd="1dp"
android:scaleType="fitXY"
android:background="#drawable/widget_wifi_btn" />
<ImageButton
android:id="#+id/widget_brightnes"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_weight="0.25"
android:layout_marginStart="1dp"
android:scaleType="fitXY"
android:background="#drawable/widget_brightnes1_btn" />
i would need to read brightness too, becouse it is wierd if that button will have drawable of 100% but someone will decrease brightness manualy to 0%...
so can someone help me to get premission for reading and writing to brightness... ?
if you will be way to kind you could help me with others staff
That's not a real error, just an error produced by your IDE. If you want to remove it, you just have to add to your Manifest:
uses-permission android:name="android.permission.WRITE_SETTINGS"
tools:ignore="ProtectedPermissions"
Edit: Thanks to everybody that helped. I found a text size library that fixes this problem.
Since I upgraded to Android Studio 3.0.1,
the text size in my app is on some devices way too small.
What can I do about that?
I put my layout file below
Thanks
And here is my layout:
<LinearLayout xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:id="#+id/listlayout2"
android:weightSum="1"
android:gravity="center_vertical"
android:orientation="vertical">
<ImageView
android:id="#+id/headerImageView"
android:layout_width="match_parent"
android:layout_height="140dp"
android:scaleType="centerCrop"
android:visibility="gone"
app:srcCompat="#drawable/example" />
<LinearLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:id="#+id/listlayout"
android:padding="16sp"
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:gravity="center_vertical"
android:layout_width="20sp"
android:layout_height="20sp"
android:id="#+id/itemicon"
android:contentDescription="icon"
android:src="#drawable/settings"
android:layout_marginLeft="30dp"
android:layout_marginStart="0dp" />
<TextView
android:id="#android:id/text1"
android:layout_width="match_parent"
android:layout_height="32dp"
android:textSize="16sp"
android:text="Testtext"
android:gravity="center_vertical"
android:layout_marginStart="14sp"
android:layout_marginLeft="14sp" />
</LinearLayout>
<ImageView
android:layout_width="match_parent"
android:layout_height="1.2dp"
app:srcCompat="#color/example"
android:id="#+id/divider"
android:layout_weight="0.03"
android:visibility="gone"/>
</LinearLayout>
It is used in a custom navigation drawer item.
You need to enter code here to set text appearance it displays as per system need
android:textAppearance="?android:attr/textAppearanceMedium
android:textAppearance="?android:attr/textAppearanceSmall
android:textAppearance="?android:attr/textAppearanceLarge
Just use:
android:textSize="30sp"
to change the text size and adapt it to your wanted size.
You can also go for dp instead of sp
If you define your textSize in dp that won't change your text size throughout the application.
Edit: change sp to dp
I tried using AndroidTreeView
https://github.com/bmelnychuk/AndroidTreeView
But after following the directions and importing it, i now receive the following errors in resource layout_selectable_item.xml which i copied into my project from the demo that came with the package.
Error:(37) No resource identifier found for attribute 'iconText' in package 'android'
Error:(37) No resource identifier found for attribute 'iconColor' in package 'android'
Error:(37) No resource identifier found for attribute 'iconFont' in package 'android'
Error:(37) No resource identifier found for attribute 'iconSize' in package 'android'
If i comment out the lines with the error from the xml file, the treeView works, but there are no icons in it, and it looks crappy, so I think these lines are needed but of course the errors...
To import it all i did was add this line to the gradle then started using the tree view in my code, and it worked (but looks crappy)..
compile 'com.github.bmelnychuk:atv:1.2.+'
Here is the xml file, can anybody help????
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:minHeight="48dp"
android:paddingLeft="10dp"
android:background="?android:attr/selectableItemBackground"
android:layout_height="match_parent">
<CheckBox
android:visibility="gone"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true"
android:layout_alignParentLeft="true"
android:id="#+id/node_selector"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
<LinearLayout
android:layout_centerHorizontal="true"
android:layout_marginLeft="28dp"
android:layout_alignWithParentIfMissing="true"
android:layout_toRightOf="#id/node_selector"
android:orientation="vertical"
android:id="#+id/picture_wrapper"
android:layout_width="wrap_content"
android:layout_centerVertical="true"
android:layout_height="wrap_content">
<View
android:id="#+id/top_line"
android:background="#12558C"
android:layout_gravity="center_horizontal"
android:layout_width="1dp"
android:layout_height="16dp" />
<com.github.johnkil.print.PrintView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:iconText="#string/ic_check_circle_blank"
android:iconColor="#12558C"
android:iconFont="fonts/material-icon-font.ttf"
android:iconSize="16dp" />
<View
android:id="#+id/bot_line"
android:background="#12558C"
android:layout_gravity="center_horizontal"
android:layout_width="1dp"
android:layout_height="16dp" />
</LinearLayout>
<TextView
android:layout_centerVertical="true"
android:textSize="16sp"
android:layout_marginLeft="10dp"
android:layout_toRightOf="#+id/picture_wrapper"
android:id="#+id/node_value"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
From github page: https://github.com/johnkil/Print
Custom views
Use PrintView as single icon in your layout.
<com.github.johnkil.print.PrintView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:print_iconText="#string/ic_android"
app:print_iconColor="#color/icon_color"
app:print_iconSize="#dimen/icon_size"/>
You need to use the app namespace, not android:
<com.github.johnkil.print.PrintView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:iconText="#string/ic_check_circle_blank"
app:iconColor="#12558C"
app:iconFont="fonts/material-icon-font.ttf"
app:iconSize="16dp" />
Add implementation 'com.github.johnkil.print:print:1.3.1' into your build.gradle file.
Also don't forget to add material-icon-font.ttf to main/assets/fonts
#Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
...
PrintConfig.initDefault(getAssets(), "fonts/material-icon-font.ttf");
...
}
I got it to work, just kept trying different things dont know what combination of things made it work unfortunatly.
I have been working on an Android Application project recently, and I've notice that some of my code IDs within a XML file will not register within the R file, and I have not been able to access the IDs within my classes. The code within the XML file will look like:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView android:layout_height="250dp"
android:layout_gravity="center"
android:src="#drawable/icon"
android:id="#+id/ivReturnedPic"
android:layout_width="250dp"></ImageView>
<ImageButton android:layout_height="wrap_content"
android:src="#drawable/icon"
android:id="#+id/ibTakePic"
android:layout_width="125dp"
android:layout_gravity="center"></ImageButton>
<Button android:text="Set Wallpaper"
android:id="#+id/bSetWall"
android:layout_width="125dp"
android:layout_height="wrap_content"
android:layout_gravity="center"></Button>
</LinearLayout>
None of theses IDs will register within the resource file.
There's problem in your xml that's why R is not being generated automatically
Remove one of extra </LinearLayout>
you must be sure that the image "icon.png" or "icon.jpg" is under your res/drawable folder.
android:src="#drawable/icon"