我有一个水平的LinearLayout
包含的TextView
后跟一个微调
旁边。这的LinearLayout
动态充气多次在一个固定的垂直的LinearLayout
包含在 RelativeLayout的
。
现在的问题是,既然我从 Theme.light
切换到 Theme.holo.light
,最后一行在 TextView中的
被削减了一半。这发生在动态文本很长,跨越多行。
我已经能够通过增加底部填充的水平的LinearLayout
包含的TextView
和微调。
这不觉得自己是一个解决方法,但更多的是黑客攻击。是否有人可以给我如何妥善解决这个问题一些建议吗?
我也看过一些其他的问题,但似乎没有任何帮助。
水平线性布局:
< XML版本=1.0编码=UTF-8&GT?;
< LinearLayout中的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:方向=横向>
<的TextView
机器人:ID =@ + ID / textView1
机器人:layout_width =150dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginRight =20dp
机器人:文本=TextView的/>
<微调
机器人:ID =@ + ID / spinner1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT/>
< / LinearLayout中>
相对布局,其中上述布局动态充气的线性布局与ID ll2_7:
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<滚动型
机器人:ID =@ + ID /滚动视图
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_above =@ + ID / relLayoutButtonNext
机器人:layout_below =@ ID / textView1>
< RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:paddingBottom会=20dp
机器人:以下属性来=10dp
机器人:paddingRight =10dp
机器人:paddingTop =10dp>
<的TextView
机器人:ID =@ + ID / textView10
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:paddingRight =30dp
机器人:文本=2.7/>
<的TextView
机器人:ID =@ + ID / textView11
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =10dp
机器人:layout_toRightOf =@ ID / textView10
机器人:文本=@字符串/ question2_7/>
<的LinearLayout
机器人:ID =@ + ID / ll2_7
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView11
机器人:layout_below =@ + ID / textView11
机器人:方向=垂直机器人:layout_marginBottom =20dp>
< / LinearLayout中>
< / RelativeLayout的>
< /滚动型>
< / RelativeLayout的>
编辑: 下面是完整的XML布局上面:
< XML版本=1.0编码=UTF-8&GT?;
< RelativeLayout的的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =match_parent
机器人:layout_height =match_parent>
<的TextView
机器人:ID =@ + ID / textView1
风格=@风格/ question_section_title
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_alignParentTop =真
机器人:文本=@字符串/ question2_header/>
< RelativeLayout的
机器人:ID =@ + ID / relLayoutButtonNext
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentBottom =真
机器人:背景=@色/ bottomBar
机器人:paddingBottom会=3DP
机器人:以下属性来=50dp
机器人:paddingRight =50dp
机器人:paddingTop =3DP>
<按钮
机器人:ID =@ + ID / buttonNext
机器人:layout_width =180dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentRight =真
机器人:的onClick =NEXTSTEP
机器人:文本=下一章
机器人:TEXTSIZE =20SP/>
<按钮
机器人:ID =@ + ID /按钮previous
机器人:layout_width =180dp
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignParentLeft =真
机器人:layout_alignParentTop =真
机器人:的onClick =previousStep
机器人:文本=previous节
机器人:TEXTSIZE =20SP/>
< / RelativeLayout的>
<滚动型
机器人:ID =@ + ID /滚动视图
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_above =@ + ID / relLayoutButtonNext
机器人:layout_below =@ ID / textView1>
< RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:paddingBottom会=20dp
机器人:以下属性来=10dp
机器人:paddingRight =10dp
机器人:paddingTop =10dp>
<的TextView
机器人:ID =@ + ID / textView10
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:paddingRight =30dp
机器人:文本=2.7/>
<的TextView
机器人:ID =@ + ID / textView11
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginBottom =10dp
机器人:layout_toRightOf =@ ID / textView10
机器人:文本=@字符串/ question2_7/>
<的LinearLayout
机器人:ID =@ + ID / ll2_7
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView11
机器人:layout_below =@ + ID / textView11
机器人:方向=垂直机器人:layout_marginBottom =20dp>
< / LinearLayout中>
<的TextView
机器人:ID =@ + ID / textView2
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView10
机器人:layout_below =@ + ID / ll2_7
机器人:文本=2.8/>
<的TextView
机器人:ID =@ + ID / textView3
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / ll2_7
机器人:layout_toRightOf =@ + ID / textView10
机器人:文本=@字符串/ question2_8机器人:layout_marginBottom =10dp/>
<的LinearLayout
机器人:ID =@ + ID / ll2_8
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView3
机器人:layout_below =@ + ID / textView3
机器人:layout_marginBottom =20dp
机器人:方向=垂直>
< / LinearLayout中>
<的TextView
机器人:ID =@ + ID / textView4
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView2
机器人:layout_below =@ + ID / ll2_8
机器人:文本=2.9/>
<的TextView
机器人:ID =@ + ID / textView5
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / ll2_8
机器人:layout_toRightOf =@ + ID / textView10
机器人:文本=@字符串/ question2_9机器人:layout_marginBottom =10dp/>
<的LinearLayout
机器人:ID =@ + ID / ll2_9
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / textView5
机器人:layout_toRightOf =@ + ID / textView10
机器人:方向=垂直机器人:layout_marginBottom =20dp>
< / LinearLayout中>
<的TextView
机器人:ID =@ + ID / textView6
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView4
机器人:layout_below =@ + ID / ll2_9
机器人:文本=2.10/>
<的TextView
机器人:ID =@ + ID / textView7
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / ll2_9
机器人:layout_toRightOf =@ + ID / textView10
机器人:文本=@字符串/ question2_10机器人:layout_marginBottom =10dp/>
<的LinearLayout
机器人:ID =@ + ID / ll2_10
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / textView7
机器人:layout_marginBottom =20dp
机器人:layout_toRightOf =@ + ID / textView10
机器人:方向=垂直>
< / LinearLayout中>
<的TextView
机器人:ID =@ + ID / textView8
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView6
机器人:layout_below =@ + ID / ll2_10
机器人:文本=2.11/>
<的TextView
机器人:ID =@ + ID / textView9
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / ll2_10
机器人:layout_toRightOf =@ + ID / textView10
机器人:文本=@字符串/ quesiton2_11机器人:layout_marginBottom =10dp/>
<的LinearLayout
机器人:ID =@ + ID / ll2_11
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView9
机器人:layout_below =@ + ID / textView9
机器人:方向=垂直机器人:layout_marginBottom =20dp>
< / LinearLayout中>
<的TextView
机器人:ID =@ + ID / textView12
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_alignLeft =@ + ID / textView8
机器人:layout_below =@ + ID / ll2_11
机器人:文本=2.11.1/>
<的TextView
机器人:ID =@ + ID / textView13
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / ll2_11
机器人:layout_toRightOf =@ + ID / textView10
机器人:文本=@字符串/ question2_11_1机器人:layout_marginBottom =10dp/>
<的LinearLayout
机器人:ID =@ + ID / ll2_11_1
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_below =@ + ID / textView13
机器人:layout_toRightOf =@ + ID / textView10
机器人:方向=垂直机器人:layout_marginBottom =20dp>
< / LinearLayout中>
< / RelativeLayout的>
< /滚动型>
< / RelativeLayout的>
解决方案
在尝试一百万个不同的事情,我想我找到了答案。
我申请了一个 LayoutGravity
的TextView的项目:
安卓layout_gravity =补
似乎解决所有的剪裁问题,我有。希望这可以帮助别人同样的问题。
I have a horizontal LinearLayout
containing a TextView
followed by a Spinner
next to it. This LinearLayout
is dynamically inflated multiple times in a fixed vertical LinearLayout
contained within a RelativeLayout
.
The problem is that since I switched from Theme.light
to Theme.holo.light
, the last line of the TextView
gets cut in half. This happens when the dynamic text is long and spans more than one row.
I have been able to fix this by adding bottom padding to the horizontal LinearLayout
containing the TextView
and Spinner
.
This does not feel like a fix, but more of a hack. Can someone please give me some advice on how to properly fix this?
I have also read some other questions, but none seem to help.
Horizontal Linear layout:
<?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="horizontal">
<TextView
android:id="@+id/textView1"
android:layout_width="150dp"
android:layout_height="wrap_content"
android:layout_marginRight="20dp"
android:text="TextView"/>
<Spinner
android:id="@+id/spinner1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"/>
</LinearLayout>
Relative layout where above layout is dynamically inflated at Linear Layout with id ll2_7:
<?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="match_parent" >
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/relLayoutButtonNext"
android:layout_below="@id/textView1" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="30dp"
android:text="2.7" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_toRightOf="@id/textView10"
android:text="@string/question2_7" />
<LinearLayout
android:id="@+id/ll2_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView11"
android:layout_below="@+id/textView11"
android:orientation="vertical" android:layout_marginBottom="20dp">
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
EDIT: Here is the complete layout xml for above:
<?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="match_parent" >
<TextView
android:id="@+id/textView1"
style="@style/question_section_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:text="@string/question2_header" />
<RelativeLayout
android:id="@+id/relLayoutButtonNext"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="@color/bottomBar"
android:paddingBottom="3dp"
android:paddingLeft="50dp"
android:paddingRight="50dp"
android:paddingTop="3dp" >
<Button
android:id="@+id/buttonNext"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:onClick="nextStep"
android:text="Next Section"
android:textSize="20sp" />
<Button
android:id="@+id/buttonPrevious"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:onClick="previousStep"
android:text="Previous Section"
android:textSize="20sp" />
</RelativeLayout>
<ScrollView
android:id="@+id/scrollView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/relLayoutButtonNext"
android:layout_below="@id/textView1" >
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingBottom="20dp"
android:paddingLeft="10dp"
android:paddingRight="10dp"
android:paddingTop="10dp" >
<TextView
android:id="@+id/textView10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:paddingRight="30dp"
android:text="2.7" />
<TextView
android:id="@+id/textView11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:layout_toRightOf="@id/textView10"
android:text="@string/question2_7" />
<LinearLayout
android:id="@+id/ll2_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView11"
android:layout_below="@+id/textView11"
android:orientation="vertical" android:layout_marginBottom="20dp">
</LinearLayout>
<TextView
android:id="@+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView10"
android:layout_below="@+id/ll2_7"
android:text="2.8" />
<TextView
android:id="@+id/textView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll2_7"
android:layout_toRightOf="@+id/textView10"
android:text="@string/question2_8" android:layout_marginBottom="10dp"/>
<LinearLayout
android:id="@+id/ll2_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView3"
android:layout_below="@+id/textView3"
android:layout_marginBottom="20dp"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="@+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView2"
android:layout_below="@+id/ll2_8"
android:text="2.9" />
<TextView
android:id="@+id/textView5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll2_8"
android:layout_toRightOf="@+id/textView10"
android:text="@string/question2_9" android:layout_marginBottom="10dp"/>
<LinearLayout
android:id="@+id/ll2_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView5"
android:layout_toRightOf="@+id/textView10"
android:orientation="vertical" android:layout_marginBottom="20dp">
</LinearLayout>
<TextView
android:id="@+id/textView6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView4"
android:layout_below="@+id/ll2_9"
android:text="2.10" />
<TextView
android:id="@+id/textView7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll2_9"
android:layout_toRightOf="@+id/textView10"
android:text="@string/question2_10" android:layout_marginBottom="10dp"/>
<LinearLayout
android:id="@+id/ll2_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView7"
android:layout_marginBottom="20dp"
android:layout_toRightOf="@+id/textView10"
android:orientation="vertical" >
</LinearLayout>
<TextView
android:id="@+id/textView8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView6"
android:layout_below="@+id/ll2_10"
android:text="2.11" />
<TextView
android:id="@+id/textView9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll2_10"
android:layout_toRightOf="@+id/textView10"
android:text="@string/quesiton2_11" android:layout_marginBottom="10dp"/>
<LinearLayout
android:id="@+id/ll2_11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView9"
android:layout_below="@+id/textView9"
android:orientation="vertical" android:layout_marginBottom="20dp">
</LinearLayout>
<TextView
android:id="@+id/textView12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignLeft="@+id/textView8"
android:layout_below="@+id/ll2_11"
android:text="2.11.1" />
<TextView
android:id="@+id/textView13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/ll2_11"
android:layout_toRightOf="@+id/textView10"
android:text="@string/question2_11_1" android:layout_marginBottom="10dp"/>
<LinearLayout
android:id="@+id/ll2_11_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/textView13"
android:layout_toRightOf="@+id/textView10"
android:orientation="vertical" android:layout_marginBottom="20dp">
</LinearLayout>
</RelativeLayout>
</ScrollView>
</RelativeLayout>
解决方案
After trying a million different things, I think I have the answer.
I applied a LayoutGravity
to the TextView item:
android:layout_gravity="fill"
Seems to solve all clipping issues I had. Hope this helps someone with the same problem.
上一篇:Android的碎片onRestoreInstanceState碎片、Android、onRestoreInstanceState
下一篇:ActionBarSherlock - android.support.v4.app.Fragment不能解析的类型。这是间接地从必需的.class文件中引用这是、间接地、类型、文件