我在FrameLayout
中有一个LinearLayout
,我想把它放在右边。试过android:layout_alignParentRight="true"
但似乎没有用。有什么想法吗?请参阅下面的代码:
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:paddingLeft="@dimen/gap_normal"
android:orientation="horizontal"
android:background="@color/grey"
android:layout_alignParentRight="true">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="right"
android:layout_alignParentRight="true">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/pb"
android:visibility="invisible"/>
<CheckableImageButton
android:id="@+id/conference_checkableimagebutton_lockstate"
android:layout_width="60dp"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:background="@android:color/white"
android:src="@drawable/conference_checkableimagebutton_lockstate_src"
android:cropToPadding="false"/>
</FrameLayout>
<com.devspark.robototextview.widget.RobotoTextView
android:id="@+id/conference_text_lockstate"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gap_normal"
android:layout_marginBottom="@dimen/gap_normal"
android:gravity="left"
android:textSize="@dimen/textsize_normal"
android:paddingRight="@dimen/gap_large"
android:text="Unlocked. When all participants have joined, lock the conference by tapping the padlock."
app:typeface="roboto_condensed_regular" />
</LinearLayout>
答案 0 :(得分:2)
试用此代码:
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:gravity="right"
android:layout_alignParentRight="true">
<ProgressBar
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:id="@+id/pb"
android:visibility="invisible"/>
<CheckableImageButton
android:id="@+id/conference_checkableimagebutton_lockstate"
android:layout_width="60dp"
android:layout_height="match_parent"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:background="@android:color/white"
android:src="@drawable/conference_checkableimagebutton_lockstate_src"
android:cropToPadding="false"/>
</FrameLayout>
<com.devspark.robototextview.widget.RobotoTextView
android:id="@+id/conference_text_lockstate"
android:layout_width="0dp"
android:layout_weight="1"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/gap_normal"
android:layout_marginBottom="@dimen/gap_normal"
android:gravity="left"
android:textSize="@dimen/textsize_normal"
android:paddingRight="@dimen/gap_large"
android:text="Unlocked. When all participants have joined, lock the conference by tapping the padlock."
app:typeface="roboto_condensed_regular" />
</RelativeLayout>
答案 1 :(得分:1)
android:layout_alignParentRight=“true”doesn't work
,因为您的父级是 LinearLayout 。 alignParentRight
(以及所有其他相对属性)仅适用于 RelativeLayouts 。