android:cliptopadding
时间: 2023-04-29 07:07:20 浏览: 56
android:cliptopadding是一个属性,当设置为true时,它将限制在View中绘制内容的区域,而不是使用整个View的区域。这可以确保在处理包括padding在内的视图大小时,内容不会溢出。
相关问题
<TextView android:id="@+id/content" style="@style/text_16_666666" android:layout_width="fill_parent" android:layout_height="450dp" android:background="#47B8EC" android:clipToPadding="false" android:gravity="center" android:lineSpacingMultiplier="1.5" android:minHeight="120.0dip" android:paddingLeft="20.0dip" android:paddingTop="15.0dip" android:paddingRight="20.0dip" android:paddingBottom="15.0dip" android:scrollbarStyle="outsideOverlay" />设置大小不变,内容滚动查看
要让TextView的大小不变,但是内容可以滚动查看,可以使用ScrollView来包含TextView,并设置TextView的高度为"wrap_content",具体实现方法如下:
1. 在布局文件中,使用ScrollView包裹TextView,并设置TextView的高度为"wrap_content":
```
<ScrollView
android:layout_width="match_parent"
android:layout_height="450dp">
<TextView
android:id="@+id/content"
style="@style/text_16_666666"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#47B8EC"
android:clipToPadding="false"
android:gravity="center"
android:lineSpacingMultiplier="1.5"
android:minHeight="120.0dip"
android:paddingLeft="20.0dip"
android:paddingTop="15.0dip"
android:paddingRight="20.0dip"
android:paddingBottom="15.0dip"
android:scrollbarStyle="outsideOverlay"
android:text="Lorem ipsum dolor sit amet, consectetur adipiscing elit. Sed non risus. Suspendisse lectus tortor, dignissim sit amet, adipiscing nec, ultricies sed, dolor."/>
</ScrollView>
```
2. 在Java代码中,获取TextView并设置其可滚动性:
```
TextView content = findViewById(R.id.content);
content.setMovementMethod(new ScrollingMovementMethod());
```
这样,TextView的大小不变,但是内容可以在ScrollView内滚动查看。
android:id="@+id/rv_list" android:layout_width="match_parent" android:layout_height="0dp" android:layout_marginBottom="50dp" android:divider="#FFFFFF" android:background="@drawable/underline" android:dividerHeight="30dp" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintTop_toBottomOf="@+id/areaState" android:layout_marginTop="4dp" android:layout_marginLeft="4dp" android:layout_marginRight="4dp" android:clipToPadding="false" android:scrollbarStyle="outsideOverlay" android:paddingBottom="20dp" android:layoutDirection="rtl" android:layout_weight="1" android:paddingTop="8dp" android:elevation="8dp"
这是一个RecyclerView的布局代码,其中设置了对齐方式、分割线、背景、边距、padding等属性。其中app:layout_constraintBottom_toBottomOf="parent"表示该控件与父布局底部对齐,app:layout_constraintTop_toBottomOf="@+id/areaState"表示该控件与id为areaState的控件底部对齐,android:clipToPadding="false"表示不裁剪padding部分的内容,android:scrollbarStyle="outsideOverlay"表示滚动条在内容之上,android:layoutDirection="rtl"表示布局方向为从右到左,android:layout_weight="1"表示该控件在布局中所占比例为1:1。最后,android:elevation="8dp"可以设置控件的高度。
相关推荐
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![pdf](https://img-home.csdnimg.cn/images/20210720083512.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)