-1
設置文本視圖的重力我試圖通過Java通過以下方式無法通過java代碼
if(check.equals("left")){
results.setGravity(Gravity.LEFT);
} else if(check.equals("center")){
results.setGravity(Gravity.CENTER);
} else if(check.equals("right")){
results.setGravity(Gravity.RIGHT);
}
設置文本視圖的重力但是,這並不正常工作。
,並且在XML文件中gravity
被預設爲center
。
這裏的結果是TextView類型變量。
這是父XML代碼:
<TextView android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Text" android:textSize="30dp" />
請幫我
和全佈局XML代碼
<EditText
android:id="@+id/etCommands"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Type some commands"
android:inputType="textPassword" >
</EditText>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100"
>
<Button
android:onClick="cmdClick"
android:layout_weight="20"
android:id="@+id/bResults"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textSize="30dp"
android:text="Try Commond" />
<ToggleButton
android:id="@+id/tgPassword"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:layout_weight="80"
android:checked="true"
android:paddingBottom="20dp"
android:text="ToggleButton"
android:onClick="togClick"
/>
</LinearLayout>
<TextView
android:id="@+id/textView1"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Text"
android:textSize="30dp"
/>
告訴我們您的XML代碼也許有問題,在XML – 2011-12-19 05:33:39
請把你的XML代碼。該問題可能來自您的父級佈局。 (編輯)你甚至沒有發佈問題。你想要做什麼,以及迄今爲止所做的結果。 – josephus 2011-12-19 05:41:20