如何在RelativeLayout中并排排列两个视图? (非线性布局)Android Studio。 XML布局宽度在此相关布局中被压缩。
我想要在屏幕右侧对齐50dp宽度的ViewPager, 并且粉红色的RelativeLayout占据了剩余的空间。
我希望避免在布局中使用“重量”。
任何解决方案,请?
<?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="120dp">
<RelativeLayout
android:id="@+id/dashboard_platform_view"
android:layout_width="match_parent"
android:background="@color/colorAccent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:orientation="vertical">
</RelativeLayout>
<android.support.v4.view.ViewPager
android:id="@+id/dashboard_platform_viewpager"
android:layout_toRightOf="@id/dashboard_platform_view"
android:layout_width="50dp"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true"
android:background="@color/colorPrimary"
android:minWidth="50dp">
</android.support.v4.view.ViewPager>
</RelativeLayout>
太棒了!谢谢! –