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.
Related
I want a layout similar to below image, where (2) is a LinearLayout and (1) is whatever it can be to make this possible.
For example imagine (2) is a button configuration and (1) is some text in different sizes and needs to go around (2).
small square inside (bottom right) big square
Seems folks misunderstand my question even with the image demonstration, (2) is not on top of (1) !!! Let me add a more detailed image as below:
embedded not on top of
I suggest you use include. Note that if you include android:id... into the <include /> tag, it will override whatever id was defined inside the included layout. For example:
<include
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/some_id_if_needed"
layout="#layout/yourlayout" />
yourlayout.xml:
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/some_other_id">
<Button
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/button1" />
</LinearLayout>
Then you would reference this included layout in code as follows:
View includedLayout = findViewById(R.id.some_id_if_needed);
Button insideTheIncludedLayout = (Button)includedLayout.findViewById(R.id.button1);
Its pretty easy, Have you done Constraint Layout? try with this.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="250dp">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="#mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:layout_width="80dp"
android:layout_height="80dp"
android:src="#mipmap/ic_launcher"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="1.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="1.0" />
</androidx.constraintlayout.widget.ConstraintLayout>
</LinearLayout>
Please try with this code (Paste this code in xml layout file) and get the result.
Note : You have to define constrains as per given here.
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.
I'm using the big image notification template as provided in the SDK (xml below). But I'm unable to compile my project after I have added this layout.
Even though I'm using the Schema: http://schemas.android.com/apk/prv/res/android which should provide layout_minHeight and layout_maxHeight.
Why do I have this problem and how can it be fixed?
Error:(5) No resource identifier found for attribute
'layout_minHeight' in package 'android'
Error:(5) No resource identifier found for attribute
'layout_maxHeight' in package 'android'
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:internal="http://schemas.android.com/apk/prv/res/android"
android:id="#+id/status_bar_latest_event_content"
android:layout_width="match_parent"
android:layout_height="match_parent"
internal:layout_minHeight="65dp"
internal:layout_maxHeight="unbounded"
>
<ImageView
android:id="#+id/big_picture"
android:layout_width="match_parent"
android:layout_height="192dp"
android:layout_marginTop="64dp"
android:layout_gravity="bottom"
android:scaleType="centerCrop"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="6dp"
android:layout_marginTop="64dp"
android:scaleType="fitXY"
android:src="#drawable/title_bar_shadow"
/>
<include layout="#layout/notification_template_material_base"
android:layout_width="match_parent"
android:layout_height="64dp"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="208dp"
android:paddingStart="#dimen/notification_large_icon_width"
android:layout_gravity="bottom"
android:background="#CCEEEEEE"
>
<include
layout="#layout/notification_material_action_list"
android:id="#+id/actions"
android:layout_gravity="bottom"
android:layout_width="match_parent"
android:layout_height="wrap_content"
/>
</FrameLayout>
</FrameLayout>
Source: http://grepcode.com/file/repository.grepcode.com/java/ext/com.google.android/android/5.0.1_r1/frameworks/base/core/res/res/layout/notification_template_material_big_picture.xml
Change xmlns:internal="http://schemas.android.com/apk/prv/res/android" to xmlns:internal="http://schemas.android.com/apk/res-auto"
I'm working on this android project on eclipse. I created two gridLayouts and a text field on main activity. It keeps on showing this warning in a window "The following classes could not be instantiated:
- android.support.v7.widget.GridLayout (Open Class, Show Error Log)" but as i try to add a button to the GridLayout, the activity freezes and now it shows following message "NOTE: This project contains Java compilation errors, which can cause rendering failures for custom views. Fix compilation problems first.
Exception raised during rendering: com.android.layoutlib.bridge.MockView cannot be cast to android.view.ViewGroup
Exception details are logged in Window > Show View > Error Log
The following classes could not be instantiated:
- android.support.v7.widget.GridLayout (Open Class, Show Error Log)" My xml file is:
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
tools:context=".MainActivity"
xmlns:app="http://schemas.android.com/apk/res/com.example.simple_calculator">
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="94dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<android.support.v7.widget.GridLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="232dp"
android:layout_marginTop="100dp" >
</android.support.v7.widget.GridLayout>
<android.support.v7.widget.GridLayout
android:layout_width="232dp"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
app:columnCount="1" >
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_column="0"
app:layout_gravity="left|top"
app:layout_row="0"
android:text="Button" />
</android.support.v7.widget.GridLayout>
</FrameLayout>
I already tried importing android-sdk-[platform]/extras/android/support/v7/gridlayout, but still same error.
Try using following code(I have modified your code, not added any other stuff) :
<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#0099cc"
tools:context=".MainActivity"
xmlns:app="http://schemas.android.com/apk/res/com.example.simple_calculator">
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="94dp"
android:text=""
android:textAppearance="?android:attr/textAppearanceLarge" />
<GridLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_marginLeft="232dp"
android:layout_marginTop="100dp" >
</GridLayout>
<GridLayout
android:layout_width="232dp"
android:layout_height="match_parent"
android:layout_marginTop="100dp"
>
<Button
android:id="#+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_column="0"
android:layout_gravity="left"
android:text="Button" />
</GridLayout>
</FrameLayout>
In this code Grid Layout and the app:column and gravity parts are modified and the exception reported was corrected and code works fine and also for the layout rules please check the following link:
http://www.curious-creature.org/2009/02/22/android-layout-tricks-1/
Hope this helps in resolving problem :)
Best Regards
Hoping this is a simple one.
I have a very simple issue here that I cant seem to solve. I'm simply trying to reference an EditText in my XML layout to the code through the use of findViewById etc. For some reason, and I have tried cleaning the project and regenerating my R resource file, along with ctrl+o to check the imports I cant get Eclipse to 'see' the link to the EditText in the XML layout.
Hopefully someone can help me with this frustrating and simple error.
Currently the error is:
totalListPrice cannot be resolved or is not a field
This is the simple code used to reference 'totalListPrice; in my XML to the EditText in my code:
totalPrice = (EditText)findViewById(android.R.id.totalListPrice);
And this is my XML layout (the problematic EditText has been marked):
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="84dp"
android:orientation="horizontal"
android:focusableInTouchMode="false">
<ImageView
android:id="#+id/imgLink"
android:layout_width="78dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="#drawable/viewcon" />
<TextView
android:id="#+id/textView1"
android:layout_width="match_parent"
android:layout_height="75dp"
android:gravity="center"
android:text="Shopping List"
android:textAppearance="?android:attr/textAppearanceLarge"
android:textSize="35sp"
android:focusableInTouchMode="false"
android:clickable="false"
android:focusable="false" />
</LinearLayout>
<TextView
android:id="#+id/txtItemDes"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="false"
android:focusable="false"
android:focusableInTouchMode="false"
android:text="Search From An Item In The List:"
android:textAppearance="?android:attr/textAppearanceMedium" />
<EditText
android:id="#+id/inputAppointName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ems="10"
android:hint="Enter An Item Name" >
<requestFocus />
</EditText>
<Button
android:id="#+id/btnAddItem"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Add"/>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="56px"
android:orientation="horizontal" >
<TextView
android:id="#+id/txtPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Total Price:"
android:textAppearance="?android:attr/textAppearanceMedium" />
*************ERROR*************
<EditText
android:id="#+id/totalListPrice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:inputType="number"></EditText>
</LinearLayout>
<ListView
android:id="#android:id/list"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
</ListView>
</LinearLayout>
It should be
R.id.totalListPrice
not
android.R.id.totalListPrice
Import local R class in your java file instead the R class of android framework
import <your package name>.R;
You don't need the "android" in front of the R. Instead, import the generated R file from your own package (you should be able to delete the import android.R line and replace it with your R import easily).
It should just be R.id.totalListPrice.