Hi I tried to used TextInputLayout for my apps, at first it's worked but the problem came while I put 'style:' attribute and my app stopped working.
Here my code, I follow from AndroidDeveloper code and tried to put style
<com.google.android.material.textfield.TextInputLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Test"
style="#style/Widget.MaterialComponents.TextInputLayout.OutlinedBox"
app:layout_constraintBottom_toBottomOf="parent">
<com.google.android.material.textfield.TextInputEditText
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</com.google.android.material.textfield.TextInputLayout>
Related
I need help.
At work, I was given a task to figure out why ScrollView overlaps part of the text. The layout is multi-layered, and I think the problem lies in this. I'm new to android studio and it's still hard for me to understand the relationships of all objects.
all the XML is here https://docs.google.com/document/d/1PaGIWPn2w6ubZraVpQfq8Rrqo0uCWYOiIbxnCWaIKTQ/edit?usp=sharing
below is a part of the code
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center|left|center_vertical"
android:orientation="vertical">
<TextView
android:id="#+id/tvMessage"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="2dp"
android:textColor="#color/mainBlackColor"
android:textSize="24dp"
tools:text="Сообщение" />
<TextView
android:id="#+id/tvDetails"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/red"
android:lines="3"
android:paddingStart="3dp"
android:paddingLeft="3dp"
android:paddingTop="2dp"
android:paddingEnd="3dp"
android:paddingRight="3dp"
android:paddingBottom="2dp"
android:textColor="#color/mainTextColor"
android:textSize="18dp"
android:visibility="gone"
app:autoSizeMaxTextSize="18dp"
app:autoSizeMinTextSize="10dp"
app:autoSizeStepGranularity="4dp"
app:autoSizeTextType="uniform"
tools:text="Детали"
tools:visibility="visible" />
</LinearLayout>
</ScrollView>
Add android:scrollbarStyle="outsideOverlay" and padding_horizontal to your scrollView. This should solve your issue.
I want to use SearchView that it the same to google play store SearchView like picture below but I don't know how do it.
May you show me sample code or google library?
Thank You!
try this my friend
add this dependency in gradle app file
compile 'com.android.support:cardview-v7:25.3.1'
now use below code
<android.support.v7.widget.CardView
android:layout_width="match_parent"
app:cardElevation="10dp"
app:cardUseCompatPadding="true"
android:layout_height="wrap_content">
<LinearLayout
android:padding="10dp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/search"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_edit"
android:drawablePadding="5dp"
android:background="#null"
android:drawableRight="#drawable/ic_delete"
android:hint="Search anything" />
</LinearLayout>
</android.support.v7.widget.CardView>
ask me in case of any query
i developed a keyboard that works without issue on MM and lower. By the way on Nougat i have a layout issue, check this images to understand better: http://imgur.com/a/IHfeZ.
The 1st image is on Nougat ( the popup isn't showed completely) the 2nd is like appeared on MM ( all the lines are showed correctly ).
I used this xml to customize the popup:
<?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="wrap_content"
android:orientation="horizontal"
android:background="#color/aosp_pressed">
<android.inputmethodservice.KeyboardView
android:layout_gravity="bottom"
android:id="#android:id/keyboardView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:keyPreviewLayout="#layout/preview"
android:keyBackground="#drawable/key_background"
android:keyTextColor="#fff"
android:background="#color/aosp_background"
android:keyTextSize="25sp"/>
<ImageButton android:id="#android:id/closeButton"
android:background="#color/aosp_pressed"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginStart="8dp"
android:layout_marginEnd="8dp"
android:clickable="true"
android:src="#drawable/ic_close_black" />
</LinearLayout>
As you can see the issue is caused by the position of the popup that isn't showed outside the keyboard. How can i solve this issue?
Thanks in advance to everyone.
What is your #layout/preview like?
My theory is that in between Android 6 and 7, the time when wrap_content chooses it's size changed.
Before when using
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal">
<TextView
android:id="#+id/xxxxx"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
</LinearLayout> //PARTIAL CODE!
there were no problems in 6.0. The text view would expand to fit the text and then be centered.
However, in 7, the text gets displayed completely vertically suggesting that the initial LinearLayout was getting set to a width of 0 and not adjusting.
Try playing with the height in your #layout/preview, or in your closeButton. Set them to manual heights and see if things change accordingly!
I am getting a strange problem using what seems like a simple layout. This is the line that keeps erring out.
android:layout_above="#id/layoutButtonOrganizer"
I does exist in the in the R.java file
**public static final int layoutButtonOrganizer=0x7f090003;**
The Error I am getting is
**error: Error: No resource found that matches the given name (at 'layout_above' with value '#id/layoutButtonOrganizer').**
It compiles fine unless I try to use the id to align a button above it.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:context="com.MasinoMike.mmasinolab4_1.MainActivity" >
<Button
android:id="#+id/buttonShowAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
***android:layout_above="#id/layoutButtonOrganizer"***
android:text="#string/buttonTextShowAnswer" />
<LinearLayout
android:id="#+id/layoutButtonOrganizer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
<Button
android:id="#+id/buttonNext"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buttonTextNext" />
<Button
android:id="#+id/buttonPrevious"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/buttonTextPrevious" />
</LinearLayout>
</RelativeLayout>
After working on this for a few hours I figured out what was going on. Even though the LinearLayout is below the button that I am referencing it from (My Button is above the layout in the xml file) I have to load the reference ID the first time it is used with the #+
android:layout_above="#+id/layoutButtonOrganizer"
The solution is to always make sure to have #+ the first time that you use a resource reference in your xml file. It feels sort counter intuitive to load the reference before creating the View object the id belongs to, but whatever makes the compiler happy.
<Button
android:id="#+id/buttonShowAnswer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
**android:layout_above="#+id/layoutButtonOrganizer"**
android:text="#string/buttonTextShowAnswer" />
<LinearLayout
**android:id="#id/layoutButtonOrganizer"**
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:orientation="horizontal" >
I'm trying to create a new layout. My last layout that I used was GridLayout and basically created a table with 3 columns and 8 rows. With rowspan I was able to achieve the look that I wanted within Eclipse however, my screen is a little longer on my phone then Eclipse is and it shows that column 1 and 2 look good, but 3 was stretched to the right.
The new layouts looks like this:
** You can see the arrow on the right side is well over the edge of the screen and I don't know why. I'm trying to create a layout that when used on different devices will scale appropriately.
The XML code is as follows:
<TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<TableRow
android:id="#+id/tableRow1"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:weightsum="1.0" >
<ImageView
android:id="#+id/arrowLeft"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:src="#drawable/arrowleftoff" />
<Space
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight=".34" />
<ImageView
android:id="#+id/arrowRight"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:src="#drawable/arrowrightoff" />
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow2"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</LinearLayout>
</TableRow>
<TableRow
android:id="#+id/tableRow3"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
</LinearLayout>
</TableRow>
</TableLayout>
The issue was caused by a lack of understanding how Eclipse works regarding layout. First, the screen shown in the Eclipse visual layout editor is an "example" of what it would look like given the selected device at the top of the window (in my case Nexus S).
Second, the Layout I was using was not anchoring to certain elements or to the parent. Therefore when the screen dimensions changed, the layout changed with it.
Conclusion: I am now using and understanding RelativeLayout and it works wonders once you figure it out.
Here is a great resource which really helped me understand what was going on: Mobile Tuts Plus: Layout Basics