我正在开发一个 Android 应用程序(与 android 2.3 及更高版本兼容),我需要制作一个封面流,其中两个导航箭头在封面流的左侧和右侧对齐
我尝试了很多方法,但无法弄清楚如何使左箭头在布局的左侧对齐,而右箭头在布局的右侧对齐。
即使我没有指定填充或边距,我总是有边距
这是屏幕截图:http://accessdev.s3.amazonaws.com/temp/layout_madness_android.jpg
我使用黑色背景来显示尺寸是正确的(父级的 100%),但我们可以看到箭头没有左/右对齐。
我检查过,问题不在图像本身内部。
这是我的布局代码,我们将不胜感激:)
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/BonsPlans_coverFlowAndArrows"
android:layout_width="match_parent"
android:layout_height="145px"
android:layout_gravity="left"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:background="#ff000000"
android:paddingLeft="0px"
android:paddingRight="0px"
>
<ImageView
android:id="@+id/bonsplans_fleche_gauche"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentLeft="true"
android:layout_marginLeft="0dip"
android:paddingLeft="0px"
android:paddingRight="0px"
android:src="@drawable/fleche_gauche" />
<ImageView
android:id="@+id/bonsplans_fleche_droite"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_marginRight="0dip"
android:paddingLeft="0px"
android:paddingRight="0px"
android:layout_toRightOf="@drawable/fleche_gauche"
android:src="@drawable/fleche_droite" />
<pl.polidea.coverflow.CoverFlow
xmlns:coverflow="http://schemas.android.com/apk/res/com.accessdev.tellmeplus"
android:id="@+id/BonsPlans_coverflow"
android:layout_width="match_parent"
android:layout_height="145px"
android:layout_centerInParent="true"
android:layout_marginLeft="0dip"
android:layout_marginRight="0dip"
android:layout_marginTop="0dip"
android:layout_toLeftOf="@+id/bonsplans_fleche_droite"
android:layout_toRightOf="@+id/bonsplans_fleche_gauche"
coverflow:imageHeight="125px"
coverflow:imageWidth="150px" />
</RelativeLayout>
最佳答案
不能用LinearLayout吗?设置左右图像的固定宽度,例如
android:layout_width="30dp"
对于中心一(它会自行调整大小)
android:layout_weight="1"
android:layout_width="0dp"
关于android - 将RelativeLayout左侧和右侧的两个图像与匹配整个可用空间的中心元素对齐,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13760914/