I am using AutoCompleteTextView in each recyclerview row, then i got the problem when dropdown show, it overlay autocompletetextview, so can see what I text in this.
Here is my xml for recyclerview adapter
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:drawme="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="8dp"
android:orientation="vertical">
<com.rafakob.drawme.DrawMeTextView
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusable="true"
android:focusableInTouchMode="true"
android:gravity="center"
android:padding="10dp"
android:textColor="#000000"
android:textSize="18sp"
android:textStyle="bold"
drawme:dm_backColor="#color/background_light"
drawme:dm_radiusTopLeft="10dp"
drawme:dm_radiusTopRight="10dp">
<requestFocus />
</com.rafakob.drawme.DrawMeTextView>
<com.rafakob.drawme.DrawMeLinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
drawme:dm_backColor="#color/grayColor70"
drawme:dm_radiusBottomLeft="10dp"
drawme:dm_radiusBottomRight="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:orientation="vertical">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp">
<AutoCompleteTextView
android:id="#+id/machine"
style="#style/Widget.AppCompat.Spinner.DropDown"
android:layout_width="match_parent"
android:layout_height="46dp"
android:layout_weight="1"
android:gravity="center" />
<CheckBox
android:id="#+id/checkbox"
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp" />
</LinearLayout>
</LinearLayout>
</com.rafakob.drawme.DrawMeLinearLayout>
</LinearLayout>
In code i'm using normal implement with using arrayAdapter, then setadapter for that autocompletetextview
In manifest i set adjustPan|adjustResize but still not working. Does anyone have solution for this?
UPDATE
I just tested with only autocompletetextview as a child of RecyclerView row. The result image below:
After reading AutoCompleteTextView document from Android, i found the solution is just use android:dropDownVerticalOffset
it's solve my problem ^.,.^
Related
I am new to android and I have created a simple block of code which has a scrollView and an image. I want this scrollview to scroll smoothly. What do I have to do for that ? I have gone through many materials over internet, but all of those use hard terminologies which I'm not able to understand. Can someone please help me ? Thanks.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android"
>
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/top_string"
android:textColor="#android:color/white"
android:textSize="16dp"
android:textScaleX="1.5"
/>
<ImageView
android:id="#+id/img"
android:layout_width="300dp"
android:layout_height="150dp"
android:src="#drawable/dg_truck_main"
android:layout_gravity="center_horizontal"
android:background="#android:color/holo_blue_light"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="#id/text_view"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/top_string2"
android:textColor="#android:color/white"
android:textSize="16dp"
android:textScaleX="1.5"
android:layout_marginTop="50dp"
android:layout_below="#id/img"
/>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
You have added ScrollView inside RelativeLayout, what I suggest is that you should place RelativeLayout inside ScrollView tag. Please go through below code,
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
android:id="#+id/scroll_view"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="#+id/text_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/top_string"
android:textColor="#android:color/white"
android:textSize="16dp"
android:textScaleX="1.5"
/>
<ImageView
android:id="#+id/img"
android:layout_width="300dp"
android:layout_height="150dp"
android:src="#drawable/dg_truck_main"
android:layout_gravity="center_horizontal"
android:background="#android:color/holo_blue_light"
android:layout_marginTop="10dp"
android:layout_centerHorizontal="true"
android:layout_below="#id/text_view"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/top_string2"
android:textColor="#android:color/white"
android:textSize="16dp"
android:textScaleX="1.5"
android:layout_marginTop="50dp"
android:layout_below="#id/img"
/>
</RelativeLayout>
</RelativeLayout>
</ScrollView>
Okay I got my answer. Since I was new to android, I thought that "smooth scroll" is something else and we have to integrate it into our project. But a scrollView already gives smooth scrolling and so we do not need to write any extra code for that.
//to make the scrollview faster
//add the below line in xml
android:fillViewport="true"
//also add the following line to your java class
// to make the scroll view faster
scrollView.fullScroll(View.FOCUS_DOWN);
scrollView.setSmoothScrollingEnabled(true);
I had a hard time resolving this issue. Finally found a solution very simple and very smooth outcome. In your recycler view set nested scrolling to false.
Two ways to achieve it.
Through xml file -
android:nestedScrollingEnabled="false"
Through java code -
recyclerView.isNestedScrollingEnabled = false
In my app I currently have two text views in an alert dialog to display the temperature and the weather description. The problem with this is that whenever the description changes, the alignment changes.
I tried having my layout as a relative layout and move around both of them with one depending on the other but this does not help me out. Any suggestions?
This is my current code:
<?xml version="1.0" encoding="utf-8"?>
<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="match_parent"
android:orientation="vertical">
<TextView
android:id="#+id/climaText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/desc"
android:layout_marginTop="18dp"
android:layout_marginStart="120dp"
android:textColor="#android:color/white" />
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/climaText"
android:layout_centerHorizontal="true"
android:layout_marginTop="13dp"
android:textColor="#android:color/white" />
</RelativeLayout>
It is happening due to change in data size , when the data is increased it will wrap the data when you will use wrap_content . I suggest you can use a parent view and fix the height.here is the code, let me know if its working. thanks
<?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="wrap_content"
android:layout_height="250px">
<TextView
android:id="#+id/climaText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_alignStart="#+id/desc"
android:layout_marginStart="120dp"
android:layout_marginTop="18dp"
android:textColor="#android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="250px">
<TextView
android:id="#+id/desc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/climaText"
android:layout_centerHorizontal="true"
android:layout_marginTop="13dp"
android:textColor="#android:color/white" />
</LinearLayout>
</LinearLayout>
I have a question for you all. When I have a simple text in an xml file in eclipse. Why doesn't the title show up?
I have searched for similar problems, but can't find it on stackoverflow. Hopefully someone can help me.
unfortunately, I can't post pictures. Well, the text: #string/ondergewicht is the title of the text.
#/string/ondergewichttekst is the text wich I've used.
And this is the code I've used. Sorry if this is a stupid question, and I'm sure it is..
<?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="horizontal" >
<TextView
android:id="#+id/ondergewichttekst"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="#string/ondergewichttekst"
android:textSize="16sp"/>
<TextView
android:id="#+id/ondergewicht"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="#string/ondergewicht"
android:textSize="30sp"
/>
</LinearLayout>
So, the ondergewichttekst is showed, but the overgewicht is not. Maybe is there something like an text order?
Hopefully someone can help me out.
Jacob
Try this code ... It works fine for me.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<TextView
android:id="#+id/ondergewichttekst"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="#string/ondergewichttekst"
android:textSize="16sp"/>
<TextView
android:id="#+id/ondergewicht"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="#string/ondergewicht"
android:textSize="30sp"
/>
</LinearLayout>
Try this one
<?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">
<TextView
android:id="#+id/ondergewicht"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="#string/ondergewicht"
android:textSize="30sp" />
<TextView
android:id="#+id/ondergewichttekst"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="#string/ondergewichttekst"
android:textSize="16sp" />
</LinearLayout>
You have horizontal orientation in your Linear Layout and your first TextView has layout_width = match_parent This doesn't make sense, there is no more room for the second TextView.
Use vertical orientation of layout or use wrap_content instead of match_parent for widths and heights.
You have android:layout_width="match_parent" in both TextViews of a horizontal LinearLayout so the first TextView is taking up all of the width. Change them to wrap_content.
<TextView
android:id="#+id/ondergewichttekst"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textStyle="italic"
android:layout_marginTop="80dp"
android:gravity="center"
android:text="#string/ondergewichttekst"
android:textSize="16sp"/>
<TextView
android:id="#+id/ondergewicht"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:textStyle="italic"
android:gravity="center"
android:layout_marginTop="1dp"
android:text="#string/ondergewicht"
android:textSize="30sp"/>
I am having problems using a RelativeLayout in a ListView. I would like to have the two EditText fields one above the other, instead they completely overlap one another. I have more text to put in each row, so side by side isn't an option.
I tried taking out all extraneous code to make it work, so this is what I have:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical" >
<ListView android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
</LinearLayout>
Here is my relative layout:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" />
<EditText
android:id="#+id/room"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/time"
android:textSize="20sp" />
</RelativeLayout>
Any help would be greatly appreciated. Thank you.
Replace
android:layout_below="#id/subject"
With
android:layout_below="#+id/time"
So That EditText with id room will be below to EditText with id time.
You need to replace android:layout_below="#id/subject"
to android:layout_below="#+id/time"
Use LinearLayout for this use case
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical>
<EditText
android:id="#+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" />
<EditText
android:id="#+id/room"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="20sp" />
</LinearLayout>
My problem is to find best view configuration for my application that have a record in the listView.
My main.xml has this content:
<LinearLayout android:id="#+id/tabName" android:orientation="vertical"
android:layout_width="match_parent" android:layout_height="match_parent">
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textConnection" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="5dp"
android:paddingRight="5dp"
android:minHeight="20dp"
/>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/textTitle" android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_vertical"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:minHeight="40dp"
/>
<ListView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/listRecord"
android:layout_width="match_parent" android:layout_height="match_parent">
</ListView>
</LinearLayout>
And the my actual row of ListView is:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="#+id/imageBox"
android:layout_width="48px"
android:layout_marginTop="13dp"
android:layout_height="48px">
</ImageView>
<TextView
android:id="#+id/longText" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
/>
<TextView
android:id="#+id/num1" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
/>
<TextView
android:id="#+id/num2" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
/>
<TextView
android:id="#+id/num3" android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center_vertical"
/>
</LinearLayout>
I tried with TableLayout but starting the application report an error in the bindView.
Can I write my XML code with only textView?
Consider that then I must add the caption of the ListView that have three image above each column with number.
Thank's.
I think the ListView is indeed your best option.
Can I write my XML code with only textView?
Yes, of course.
I don't see what is your problem actually. You should have an activity layout with the textConnection, the textTitle, then the 3 images aligned to the right (missing in your layout file), and the listview.
As for the row xml layout, I think it is OK! Just combine it with a simple cursor adapter in your java code, and you're done.