Jul*_*Jul 8 android clipping grid-layout textview
我使用GridLayout使用库兼容性时遇到问题(没有尝试过).我正在使用app:layout_gravity="fill_horizontal"
而不是显示android:layout_gravity="fill_horizontal"
内部的所有内容TextView
.为了显示所有内容,我必须设置TextView
"标题"的高度,但我想要一个动态高度,而不是设置高度.
任何的想法?
Ser*_*kyi 30
您必须设置layout_width="0dp"
和layout_gravity="fill_horizontal"
为TextView.
<TextView
android:layout_width="0dp"
android:layout_gravity="fill_horizontal" />
Run Code Online (Sandbox Code Playgroud)
请在此处查看完整示例:https://groups.google.com/d/msg/android-developers/OmH3VBwesOQ/ZOGR0SGvC3cJ或此处:http://daniel-codes.blogspot.com/2012/01/gridlayout-view -clipping-issues.html
sul*_*lai 19
使用TextView
里面GridLayout
是有问题的,但有是同时使用起来的好办法.
这就是示例布局的样子:
这是完整的布局xml,重要的行标有***.
<?xml version="1.0" encoding="utf-8"?>
<GridLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:columnCount="3" * this example uses 3 columns
android:orientation="horizontal" > *** use "horizontal"
<TextView * just a normal view
android:layout_column="0"
android:layout_row="0"
android:background="#666666"
android:text="A"
android:textColor="#afafaf"
android:textSize="60sp"
android:textStyle="bold" />
<TextView * this text will not be cut!
android:layout_width="0dp" *** important: set width to 0dp
android:layout_height="wrap_content"
android:layout_column="1"
android:layout_columnSpan="2" * colspan does also work with this
android:layout_gravity="fill_horizontal|bottom" *** set to "fill*"!
android:layout_row="0"
android:text="This view has 2 columns. Lorem ipsum dolor sit amet, consetetur sadipscing elitr."
android:textColor="#666666" />
</GridLayout>
Run Code Online (Sandbox Code Playgroud)
根据您的需要,这种组合也可以使用:
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_gravity="fill"
android:gravity="bottom"
Run Code Online (Sandbox Code Playgroud)
请注意,除此之外,您不必使用任何命名空间android
.
归档时间: |
|
查看次数: |
8160 次 |
最近记录: |