在安卓中,只有垂直的linearlayout属性里面的内部组件靠左靠右才有效,同理,水平的linearlayout属性里面的内部组件靠上靠下才有效,否则无效由此考虑如何让水平linearlayout中同一行内组件靠左靠右显示呢。废话不多说,直接上代码,注意点,标红。
<LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:gravity="center_vertical|right"> <LinearLayout android:layout_width="match_parent" android:layout_height="wrap_content" android:orientation="vertical" android:layout_weight="1"> <Switch android:id="@+id/hand_send_switch" android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_margin="@dimen/self_help_dp_10" android:layout_gravity="left|center_v