I have implemented a custom Adapter for my AutoCompleteTextView along with a custom list item view for the suggestions. Everything works except the suggestions dialog clips the suggestions. This is most likely caused by the fact that the textview is multiline but I can't figure out how to tell the suggestions popup to expand to fill the entire view. Here is my code for the view:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/name"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:ellipsize="none"
android:textColor="#android:color/black"
android:textSize="15dp"
android:padding="10dp" />
</RelativeLayout>
Here is an image to what it looks like:
I also noticed that it doesn't clip if the android version is higher, I am testing on 2.3.5 and it clips (my phone) but on 4.1 (emulator) it looks fine.
Anyone know how to fix this?
Related
I don't understand this issue. I'm pretty sure I used to do this, yet in this case, the zindex ordering is not followed, and the TextView below is hidden behind the button:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:text="Button"
android:layout_width="match_parent"
android:layout_height="50dp" />
<TextView
android:textColor="#color/black"
android:text="TextView"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</RelativeLayout>
I have restarted Android Studio, but even worse, this is the same on my device too, so its not an Android Studio bug. What is the issue here exactly?
Please use the elevation
android:elevation="10dp"
here is you can see your solution
If you add any views to Relative Layout, It places your view above another view if you don't use layout alignment like layout_above/layout_below/layout_leftof or rightof etc
For the last two hour and a half i had been trying to do something really simple: change the padding in the Android's AutoCompleteTextView's popup (the one that shows the auto complete options).
i'm trying to do this because the item in my app has the height of the text (i'm not sure why), so i want to make it easier to click on. But every think i could find didn't work at all.
So i really would be glad if anyone could spot a light in this problem or give an alternative solution.
And just for the record, i'm using android studio, and i had removed the support API (since my min API is 16), so my app is using 100% native resorts only.
I just found a way to make it, i had to make a custom view layout with an textview already including the item's padding. Than i created a custom adapter with uses this layout.
The layout goes like this
<?xml version="1.0" encoding="utf-8"?>
<TextView xmlns:android="http://schemas.android.com/apk/res/android"
android:singleLine="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:ellipsize="marquee"
android:layout_margin="0dp"
android:paddingLeft="#dimen/thin_margin"
android:paddingRight="#dimen/thin_margin"
android:paddingTop="#dimen/list_1line_item_padding"
android:paddingBottom="#dimen/list_1line_item_padding"/>
And in the custom adapter just used it in the getView method
itemView = LayoutInflater.from(ctx).inflate(R.layout.list_1line_item, null);
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_marginTop="20dp"
>
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingTop="#dimen/dp_15"
android:paddingBottom="#dimen/dp_15"
android:id="#+id/parentid">
<AutoCompleteTextView
android:id="#+id/address_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/light_gray_bg"
android:drawableRight="#drawable/icon_search_smaller"
android:gravity="center_vertical"
android:hint="Start typing location"
android:inputType="textCapWords"
android:popupBackground="#drawable/auto_location_popup_bg"
android:textColor="#color/black"
android:textColorHint="#color/dark_grey"
android:textSize="16sp"
android:visibility="visible"
android:dropDownWidth="wrap_content"
android:dropDownAnchor="#+id/parentid">/>
<requestFocus />
</RelativeLayout>
</RelativeLayout>
define another relative layout wrapping only the autocomplete textview and the button. look at this link
Android layout padding is ignored by dropdown
Padding issue?
Update Sample of the issue:-
(Why is there a gap above the word "Late")
Update 2
Others gave reported similar issues here:- http://code.google.com/p/android/issues/detail?id=22493
So it seems that a textview doesn't reduce in size once it's been bigger. Any ideas for workarounds for this? setting the height explicitly causes the text to be cropped as it's lower than it should be.
I have a layout as follows:-
<?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="wrap_content"
android:padding="1dp"
android:orientation="vertical"
android:background="#color/Green">
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/datetext"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="14sp"
android:textStyle="bold" />
<TextView
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/DateCode"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="40sp"
android:textStyle="bold"
android:background="#color/Red" />
</LinearLayout>
and it is populated into a this GridView to form a calendar:-
<GridView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/gridview"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:numColumns="7"
android:verticalSpacing="2dp"
android:horizontalSpacing="2dp"
android:stretchMode="columnWidth"
android:gravity="center"
/>
The adapter used to populate the gridview with the items changes the text size of #+id/DateCode to fit the text to the width of the available space. it then invalidates the textview and forces a re-layout (I know this works as the bottom of the textview does come up to the bottom of the resized text).
The top of the text within DateCode seems to start at least halfway down the TextView (which is clear as a red box. I don't understand why the area is not shrunk to fit the text in.
I assume it's a padding issue or something I don't understand, but it doesn't seem to be the font padding given how big it is.
Any ideas why the textview is positioning the text so far down, and not wrapping it into a much smaller space?
Anthony
If you are using ADT in Eclipse, then use the Hierarchy Viewer perspective to inspect live Views. That way you can know for sure what is going on with the layout; but to me the two TextViews look suspicious (i.e. where is the other? is it empty?)
I am trying to get three images to display on the "welcome screen" of my Android app. Only one of the images is being displayed, and I cant figure out why... any Help?
XML File:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="center"
android:background="#drawable/main_bg"
>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:paddingTop="30dip"
android:layout_height="wrap_content"
android:gravity="center"
>
<ImageButton
android:id="#+id/mnwvbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="15dip"
android:background="#drawable/mnwvicon" />
<ImageButton
android:id="#+id/reportsbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/reportsicon" />
</LinearLayout>
<ImageButton
android:id="#+id/mnwvshowbutton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/showicon"
android:paddingTop="30dip" />
</LinearLayout>
I have the exact same set up in another app, so I dont know why it isnt working here??
I think its because the last image is outside the inner linearlayout so put it inside the inner linearlayout and you should be able to see all three images in a row.
Try scaling the images using the attribute android:ScaleType="centre" inside the ImageButton
or try a different layout like Tablayout for arranging the images in rows and columns with proper spacing.
Sorry guys. I didnt have the app support the different screen sizes. I am not sure why this mattered, but once I added support, then it worked perfectly!. Thanks for your input though! Anyone know why this mattered though?? I dont know why supporting screen sizes matters?
I've got a small clipping problem that I haven't been able to solve using an EditText view in a TableRow. Whatever I try, the EditText view is either clipped (attached screenshot), or, if I set shrinkColumns to either 0 or 1, the label text disappears (and the EditText view takes up the whole width). The layout is as follows:
<?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" android:padding="10dip">
<TableLayout android:orientation="vertical"
android:layout_width="fill_parent" android:layout_height="fill_parent">
<TableRow android:orientation="horizontal"
android:layout_width="fill_parent" android:layout_height="wrap_content">
<TextView android:paddingRight="10dip" android:layout_column="1"
android:text="Label Text" />
<EditText android:text="Very long text that makes the text view go on clipping frenzy"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</TableRow>
</TableLayout>
</LinearLayout>
I've tried it on a 2.2 emulator running at QVGA and HVGA, a HTC Hero on 2.1 and the Wildfire on 2.1 as well. I've also played around with the clipToPadding attribute which doesn't seem to help in my case. The same issue appears if I set the hint attribute with a long text and leave the text value empty.
As I am doing nothing particularly complex, I suspect a simple error on my side. Any ideas, hints or suggestions are highly appreciated.
Cheers!
Set android:shrinkColumns="1" on your TableLayout, and remove android:layout_column="1" from the TextView.
Add android:layout_weight="1", to your EditText, It took a while to resolve it..........
But don't know the reason for it.......