중력 중심 텍스트를 만들었지 만 여전히 왼쪽에 있습니다. 텍스트 정렬을 변경하는 방법이 있어야한다고 가정합니다. (나는 android : textAlignment = "center"도 시도했습니다.)가운데 맞춤 단추의 텍스트
아래 스크린 샷을 포함 시켰지만 표시 할만한 평판은 충분하지 않습니다.
<!-- language: lang-xml-->
<Button
android:id="@+id/button1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="50"
android:gravity="center"
android:text="Button" />
또한 동일한 문제로 match_parent를 만들려고했습니다. 전체 XML
<!-- language: lang-xml-->
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<EditText
android:id="@+id/etCommands"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:hint="Type a Command"
android:password="true" >
</EditText>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:weightSum="100" >
<Button
android:id="@+id/button1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="Button" />
</LinearLayout>
<TextView
android:id="@+id/tvResults"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:text="invalid" />
</LinearLayout>
기본적으로 중앙에 배치됩니다. – Ahmad
예 제가 시도한 것을 의미하는 것을 알고 있습니다. –
그냥'android : gravity = "center"를 제거하십시오 – Ahmad