Words get cut of in Android ListView - android

I'm stuck with a small problem in my listview. I tried several things like adding padding or changing the margins. But this didn't fix my problem.
Words keep getting cut of in the last rule.
<?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="match_parent"
android:divider="?android:dividerVertical"
android:showDividers="middle"
android:dividerPadding="8dp">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:id="#+id/violationstitlebar"
>
<TextView
android:layout_width="#dimen/violation_list_col1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolPos"/>
<TextView
android:layout_width="#dimen/violation_list_col2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolDescriptionNLB"/>
<TextView
android:layout_width="#dimen/violation_list_col3"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="#dimen/violation_list_col4"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskDescriptionFRB" />
<TextView
android:layout_width="#dimen/violation_list_col5"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
<TextView
android:layout_width="#dimen/violation_list_col6"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolBLS"/>
<TextView
android:layout_width="#dimen/violation_list_col7"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:text="#string/resTaskviolRepeat"
/>
<TextView
android:layout_width="#dimen/violation_list_col8"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
/>
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:divider="?android:dividerVertical"
android:showDividers="middle"
android:dividerPadding="8dp"
>
<TextView
android:layout_width="#dimen/violation_list_col1"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListPosition"
android:paddingLeft="10dp"
android:paddingBottom="10dp"/>
<TextView
android:layout_width="#dimen/violation_list_col2"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListDescription"
android:layout_weight="1"
android:maxLines="4"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col3"
android:layout_height="50dp"
android:id="#+id/ibViolListEditDesc"
/>
<TextView
android:layout_width="#dimen/violation_list_col4"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:text=""
android:id="#+id/tvViolListDescriptionFRB"
android:layout_weight="1"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col5"
android:layout_height="50dp"
android:id="#+id/ibViolListEditDescFRB"
/>
<Spinner
android:layout_width="#dimen/violation_list_col6"
android:layout_height="wrap_content"
android:id="#+id/spViolListConclusion"
style="?android:dropDownSpinnerStyle"/>
<EditText
android:layout_width="#dimen/violation_list_col7"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceMedium"
android:id="#+id/etViolListCounter"
android:inputType="number"
/>
<ImageButton
android:layout_width="#dimen/violation_list_col8"
android:layout_height="50dp"
android:id="#+id/ibViolListDelete"
/>
</LinearLayout>
</LinearLayout>
Does anyone have an idea how to fix this?
kind regards,
Tim

give some limitaion to charaters ,while adding the content of your NLB
maxlines, minimum lines
<EditText
android:id="#+id/AddressEdittext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/textView4"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:layout_marginTop="15dp"
android:background="#drawable/retangle_shape"
android:gravity="top|left"
android:hint="Type Here..."
android:inputType="textMultiLine"
android:lines="5"
android:maxLines="10"
android:minLines="5"
android:paddingBottom="5dp"
android:paddingLeft="#dimen/padding"
android:paddingRight="#dimen/padding"
android:paddingTop="5dp"
android:scrollbars="vertical" >
</EditText>

Try using this property also with some padding bottom:
android:includeFontPadding="false"
And:
android:baselineAligned="false"

I think you can solve it with layout_weight attribute.
More info on layout_weight can be found on:
http://ugia.io/2012/01/19/android-linearlayout-distribution-explained-weight-and-sizes/
http://developer.android.com/guide/topics/ui/layout/linear.html

Related

RelativeLayout android:gravity not use below api 16?

I write to show a video's name and mark.
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingBottom="7dp" >
<TextView
android:id="#+id/drama_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:includeFontPadding="false"
android:textColor="#ff9313"
android:textSize="16dp"
android:layout_marginLeft="8dp"
android:text="8.8"/>
<TextView
android:id="#+id/drama_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:gravity="left|end"
android:textColor="#ff323232"
android:textSize="16dp"
android:text="See you again"
android:layout_toLeftOf="#id/drama_mark" />
</RelativeLayout>
But it not use below android 16.Why it show in right?The video, name maybe two or more lines.I have try many times ,please help me.
Try this:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:gravity="left"
android:paddingBottom="7dp" >
<TextView
android:id="#+id/drama_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:textColor="#ff9313"
android:layout_alignParentRight="true"
android:textSize="16dp"
android:layout_marginLeft="8dp"
android:text="8.8"/>
<TextView
android:id="#+id/drama_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:gravity="left|start"
android:textColor="#ff323232"
android:layout_alignParentLeft="true"
android:textSize="16dp"
android:layout_toLeftOf="#+id/drama_mark"
android:text="See you again gbfayufbafubsayfbas fysgafysaf fyasgfysuafas" />
</RelativeLayout>
Finally I use TableLayout to solve my question.
<TableLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:paddingTop="#dimen/distance"
android:paddingBottom="7dp"
android:shrinkColumns="0">
<TableRow>
<TextView
android:id="#+id/drama_name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:includeFontPadding="false"
android:textColor="#ff323232"
android:text="see you again"
android:textSize="16dp" />
<TextView
android:id="#+id/drama_mark"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:singleLine="true"
android:includeFontPadding="false"
android:textColor="#ff9313"
android:textSize="#dimen/big_text"
android:layout_marginLeft="16dp"
android:text="8.8" />
</TableRow>
</TableLayout>

Align textviews in linearlayout

This is what I want to achieve:
main.xml
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" >
<TextView
android:id="#+id/tvNameContainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_marginLeft="2dip"
android:layout_weight="0.29"
android:textColor="#FFF"
android:gravity="center_horizontal"
android:text="#string/fullname"
android:textStyle="bold" />
<TextView
android:id="#+id/tvDiagnosisContainer"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginBottom="3dp"
android:layout_weight="0.57"
android:gravity="center_horizontal"
android:text="#string/diagnosis"
android:textColor="#color/white"
android:textStyle="bold" />
</LinearLayout>
custom_row.xml
<?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="vertical"
android:layout_marginLeft="15dp"
android:layout_marginRight="15dp" >
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/fullname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginRight="10dp"
android:layout_weight="0.29"
android:text="text"
android:textColor="#color/black" />
<TextView
android:id="#+id/lname"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="0.29"
android:text="text"
android:textColor="#color/black" />
<TextView
android:id="#+id/diagnosis"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.57"
android:text="#string/diagnosis"
android:padding="5dp"
android:textColor="#color/black" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<TextView
android:id="#+id/lastffupcontainer"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lastffup"
android:padding="5dp"
android:textColor="#color/black" />
<TextView
android:id="#+id/lastffup"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/lastffup"
android:padding="5dp"
android:textColor="#color/black" />
</LinearLayout>
</LinearLayout>
This is the result:
But I can't seem to make those spaces between the textviews. Any ideas?
Correct me if I'm wrong but it looks like the only issue you are having is having the "Diagnosis" TextView in the ListView spaced more to the right. For this I would change that LinearLayout to a RelativeLayout. Then you can give it the property android:layout_alignParentRight="true" and add in some android:marginRight="some dp" if needed.
You can use Android's new fancy GridLayout (http://developer.android.com/reference/android/widget/GridLayout.html or http://developer.android.com/reference/android/support/v7/widget/GridLayout.html) to get exactly what you're looking for.
Try and replace your LinearLayout tags with GridLayout instead and it just might work for you. (make sure you add the support library to your project if you need to support devices < api 14).

Layout TextView Hint not always showing

I have 4 textview, all numbers. The first one "#" is the hint and it shows up on my 4.2 and 2.2. The next three are "Hours, Minutes, Seconds" respectively and the hint shows up on 4.2 but not 2.2. Here is my xml for the them.
First Textview has # and the next three will say Hour, Minute, Second.
<ScrollView
android:id="#+id/mainBodyScroll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="#+id/calculateButton"
android:layout_alignParentLeft="true"
android:layout_below="#+id/perDistanceLayout"
android:fadeScrollbars="false"
android:paddingLeft="10dp"
android:paddingRight="10dp" >
<LinearLayout
android:id="#+id/mainBodyLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<TextView
android:id="#+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/default_distance"
android:textAppearance="?android:attr/textAppearanceLarge" />
<LinearLayout
android:id="#+id/distanceEntryLinear"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="5dp" >
<EditText
android:id="#+id/distanceText"
android:layout_width="50dp"
android:layout_height="wrap_content"
android:ems="10"
android:hint="#string/default_number_hint"
android:inputType="number"
>
</EditText>
<Spinner
android:id="#+id/spinnerInput"
android:layout_width="wrap_content"
android:layout_height="fill_parent"
android:entries="#array/spinner2_array" />
</LinearLayout>
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/default_in"
android:textAppearance="?android:attr/textAppearanceMedium" />
<LinearLayout
android:id="#+id/timeLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingLeft="5dp"
android:paddingRight="5dp" >
<EditText
android:id="#+id/hourText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="#string/default_hours"
android:inputType="number" />
<EditText
android:id="#+id/minuteText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="#string/default_minutes"
android:inputType="number" />
<EditText
android:id="#+id/secondText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight=".33"
android:ems="10"
android:gravity="center_vertical|center_horizontal"
android:hint="#string/default_seconds"
android:inputType="number" />
</LinearLayout>
<Button
android:id="#+id/paceclearButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginRight="5dp"
android:minHeight="32dip"
android:text="#string/default_clear"
android:textSize="12dp" />
</LinearLayout>
</ScrollView>
Somehow setting center_horizontal value in the android:gravity is causing issues in Android 2.2 in displaying the hint.
Remove center_horizontal from the value of android:gravity to display the hint.

RelativeLayout wrap_content width, circular dependency

Want to design a custom marker-baloon for the new Google Maps v2 API for Android. I have overridden getInfoContents but my now the layout takes the full width of the screen with ym custom design. I want it to wrap around the text with a max width.
I have found my problem after reading online, its probably that I have circular dependency in the RelativeLayout which is not permitted. But then how would I move the textfield "place" to the right of the layout, in line with the title but on the right side?
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="2sp"
android:paddingLeft="5sp"
android:paddingTop="1sp"
android:textColor="#color/list_item_title_color"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"sa
android:layout_below="#id/title"
android:ellipsize="end"
android:maxLines="3"
android:paddingBottom="3sp"
android:paddingLeft="5sp"
android:paddingRight="5sp"
android:textColor="#color/list_item_text_color"
android:textSize="13sp" />
<TextView
android:id="#+id/place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:gravity="right"
android:paddingRight="5sp"
android:paddingTop="1sp"
android:textColor="#color/list_item_date_color"
android:textSize="13sp" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/icons"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_below="#id/place"
android:gravity="right"
android:orientation="vertical"
android:paddingBottom="2sp"
android:paddingLeft="5sp"
android:paddingRight="5sp" >
</LinearLayout>
</RelativeLayout>
Can't you just add:
android:layout_toRightOf="#id/title"
to your place textview?
EDIT:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<RelativeLayout
android:id="#+id/leftLayout"
android:layout_alignParentLeft="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:ellipsize="end"
android:maxLines="1"
android:paddingBottom="2sp"
android:paddingLeft="5sp"
android:paddingTop="1sp"
android:textColor="#color/list_item_title_color"
android:textSize="15sp"
android:textStyle="bold" />
<TextView
android:id="#+id/text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"sa
android:layout_below="#id/title"
android:ellipsize="end"
android:maxLines="3"
android:paddingBottom="3sp"
android:paddingLeft="5sp"
android:paddingRight="5sp"
android:textColor="#color/list_item_text_color"
android:textSize="13sp" />
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="#+id/icons"
android:layout_width="fill_parent"
android:layout_height="32dp"
android:layout_below="#id/place"
android:gravity="right"
android:orientation="vertical"
android:paddingBottom="2sp"
android:paddingLeft="5sp"
android:paddingRight="5sp" >
</LinearLayout>
</RelativeLayout>
<TextView
android:id="#+id/place"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_toRightOf="#id/leftLayout"
android:gravity="right"
android:paddingRight="5sp"
android:paddingTop="1sp"
android:textColor="#color/list_item_date_color"
android:textSize="13sp" />
</RelativeLayout>
Here, try this, but it's not tested.
Unless I misunderstand, you should be able to wrap the "title, place, and text" in a linearlayout
<LinearLayout
android:id="#+id/textLL
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
//textViews
</LinearLayout>
now use
android:layout_toRightOf="#+id/textLL"
in your "icons" layout. Or is this not what you want?

android text in table gets cut off

I've been looking for an answer to this for a long long long time.
I have the following code:
<TableRow
android:id="#+id/tableRow106"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:visibility="gone"
android:background="#drawable/b02_light_bar">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content" >
<Button
android:id="#+id/button35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/b02_play_blue"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
>
<TextView
android:id="#+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:text="#string/interaction2"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#41c4dd"
android:text="#string/interaction2cont"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
</TableRow>
And my text in textview21 still gets cut off if it is too long.
Anyone know how to solve this?
I promise you, I tried everything!
I have copied your code and string and yes the problem is there..
I got one solution for you and that's
Remove android:padding="10dp" from TableRow tag and apply that in the LinearLayout right under the tableRow.
<TableRow
android:id="#+id/tableRow106"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
android:background="#drawable/b02_light_bar">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
>
<Button
android:id="#+id/button35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/b02_play_blue"
/>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"
android:paddingLeft="5dp"
>
<TextView
android:id="#+id/textView20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#ffffff"
android:text="#string/interaction2"
android:textAppearance="?android:attr/textAppearanceMedium" />
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#41c4dd"
android:text="#string/interaction2cont"
android:textAppearance="?android:attr/textAppearanceSmall" />
</LinearLayout>
</LinearLayout>
</TableRow>
use the attribute android:maxLines="3"
Change your textview to
<TextView
android:id="#+id/textView21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="#41c4dd"
android:maxLines="3"
android:text="#string/interaction2cont"
android:textAppearance="?android:attr/textAppearanceSmall" />

Categories

Resources