<LinearLayout
android:id="@+id/tipTitleLayout"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="2dp"
android:gravity="center_horizontal"
android:orientation="horizontal" >
<com.me.view.text.MyTextView
android:id="@+id/tipTitleText"
style="@style/popupTitle"
android:layout_width="wrap_content"
android:layout_height="60dp"
android:layout_alignParentTop="true"
android:layout_gravity="left"
android:layout_marginLeft="5dp"
android:layout_marginRight="38dp"
android:layout_marginTop="10dp"
android:gravity="left"
android:text="Tip" />
</LinearLayout>
但是当 ltrMode 打开时,我的代码不会改变重力。
我想以编程方式更改它。
怎么来的?
private void setUpforRTL(){
if (AppService.getNativeManager().getLanguageRtl()) {
TextView addText2 = ((TextView)findViewById(R.id.tipText));
addText2.setGravity(Gravity.RIGHT);
TextView title = ((TextView)findViewById(R.id.tipTitleText));
title.setGravity(Gravity.RIGHT);
LinearLayout.LayoutParams params = (LinearLayout.LayoutParams)title.getLayoutParams();
params.gravity = Gravity.RIGHT;
title.setLayoutParams(params); //causes layout update
}
}