如何在运行时将android:layout\u centerHorizontal=“true”更改为“false”
我想知道如何动态更改FrameLayout的布局如何在运行时将android:layout\u centerHorizontal=“true”更改为“false”,android,android-framelayout,Android,Android Framelayout,我想知道如何动态更改FrameLayout的布局 <FrameLayout android:id="@+id/myFrameLayout" android:layout_width="fill_parent" android:layout_height="fill_parent" android:layout_centerHorizontal="true" > </FrameLayout> 使用以下示例代码更改RelativeLa
<FrameLayout
android:id="@+id/myFrameLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_centerHorizontal="true"
>
</FrameLayout>
使用以下示例代码更改RelativeLayout中视图的属性
使用以下示例代码更改RelativeLayout中视图的属性
android:layout\u centerHorizontal用于父布局,这意味着它的父布局必须是相对的,而不是它本身。 下面的示例代码适用于表示为RelativeLayout.TRUE的mere,表示为TRUE,表示为0表示为false:
TextView mTextView = (TextView) findViewById(R.id.textView);
RelativeLayout.LayoutParams rl = (LayoutParams) mTextView.getLayoutParams();
rl.addRule(RelativeLayout.CENTER_HORIZONTAL, 0);
mTextView.setLayoutParams(rl);
android:layout\u centerHorizontal用于父布局,这意味着它的父布局必须是相对的,而不是它本身。 下面的示例代码适用于表示为RelativeLayout.TRUE的mere,表示为TRUE,表示为0表示为false:
TextView mTextView = (TextView) findViewById(R.id.textView);
RelativeLayout.LayoutParams rl = (LayoutParams) mTextView.getLayoutParams();
rl.addRule(RelativeLayout.CENTER_HORIZONTAL, 0);
mTextView.setLayoutParams(rl);
你可能需要RelativeLayout而不是FrameLayout你可能需要RelativeLayout而不是FrameLayout Hanks,这是工作!显然,我不能在15票之前投票,但是谢谢,这是工作!显然,我不能在15分钟前投票,但是thx。