Ida*_*dan 2 android android-layout
我有一个RelativeLayout,里面有一个ImageView。RelativeLayout 是一个 ListView 行,并且设置了填充(空间位于 ListView 的边缘与其子 RelativeLayout 视图的边缘之间)。
我试图让RelativeLayout 中的ImageView 比使用负边距的行更宽。设置负边距和禁用剪辑(一直向上)。似乎没有任何效果。
代码示例(RelativeLayout 在其边缘到屏幕边缘之间有父项和空间):
<RelativeLayout
android:layout_width="match_parent"
android:clipChildren="false"
android:clipToPadding="false"
android:layout_height="match_parent">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="-10dp"
android:layout_marginRight="-10dp" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
尝试这样的事情(代码来自我正在处理的项目):
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:clipChildren="false">
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
tools:ignore="UselessParent"
android:layout_width="match_parent"
android:layout_height="45dp"
android:background="@drawable/dialog_heading_top_line"
android:clipChildren="false"
android:orientation="horizontal"
android:gravity="center_horizontal">
<ImageView
android:id="@+id/default_header_logo"
android:layout_width="167dp"
android:layout_height="72dp"
android:scaleType="center"
android:src="@drawable/default_header_logo"
android:contentDescription="@string/default_heading_logo" />
</LinearLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
看起来 clipping = false 在 RelativeLayout 中并不能很好地工作,所以使用带有子元素的 LinearLayout - ImageView。
| 归档时间: |
|
| 查看次数: |
4921 次 |
| 最近记录: |