2012-12-21 2 views
0

세로 및 가로 가운데에 textView10을 설정해야합니다. 나는 결과없이 많은 노력을했습니다 ... 중력 옵션을 시도했지만 아무것도 ... 어떤 생각? textView10이 (가) scrollview 내에 있습니다. 도와 주셔서 감사합니다.TextView를 가운데 세로 및 가로로 설정하십시오.

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="fill_parent" 
    android:background="#000000" 
    android:orientation="vertical" > 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1"> 

    <TextView 
     android:layout_width="151dp" 
     android:layout_height="fill_parent" 
     android:textSize="15pt" /> 

    <ScrollView 
     android:id="@+id/scrollView10" 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:background="#000000" > 

    <TextView 
     android:id="@+id/textView10" 
     android:layout_width="match_parent" 
     android:layout_height="match_parent" 
     android:background="#000000" 
     android:gravity="center_vertical" 
     android:textAlignment="center" 
     android:textColor="#ffffff" 
     android:textSize="13sp" 
     android:textStyle="italic" /> 

    </ScrollView>  

</LinearLayout> 

    <Button 
     android:id="@+id/button10" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="Chiudi" /> 

</LinearLayout> 

답변

1
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="fill_parent" 
android:layout_height="fill_parent" 
android:background="#000000" 
android:orientation="vertical" > 

<LinearLayout 
    xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="horizontal" > 

    <TextView 
     android:layout_width="151dp" 
     android:layout_height="fill_parent" 
     android:textSize="15pt" /> 

    <ScrollView 
     android:id="@+id/scrollView10" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:background="#000000" > 

     <TextView 
      android:id="@+id/textView10" 
      android:layout_width="match_parent" 
      android:layout_height="320dp" 
      android:background="#000000" 
      android:gravity="center" 
      android:textColor="#ffffff" 
      android:textSize="13sp" 
      android:text="Hi What is your name" 
      android:textStyle="italic" /> 
    </ScrollView> 
</LinearLayout> 

<Button 
    android:id="@+id/button10" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Chiudi" /> 

+0

멋진 소년! 감사! –

1

외부 레이아웃을 RelativeLayout으로 변경하고 ScrollView를 부모 센터에 배치하십시오. 센터

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:id="@+id/RelativeLayout1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:orientation="horizontal" > 
    <TextView 
     android:id="@+id/TextView1" 
     android:layout_width="151dp" 
     android:layout_height="fill_parent" 
     android:textSize="15pt" /> 
    <ScrollView 
     android:id="@+id/scrollView10" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:background="#000000" > 
     <TextView 
      android:id="@+id/textView10" 
      android:layout_width="fill_parent" 
      android:layout_height="fill_parent" 
      android:background="#000000" 
      android:gravity="center_vertical" 
      android:textAlignment="center" 
      android:textColor="#ffffff" 
      android:textSize="13sp" 
      android:textStyle="italic" /> 
    </ScrollView> 
</RelativeLayout> 
+0

+1 원인이 용액 텍스트 뷰 고정 배치 높이를 포함하지 않는다. 외부 RelativeLayout은 모든 크기/위치로 설정 될 수 있으며 여전히 작동합니다. – sunadorer

0

한 관련 위치 다른 요소는 RelativeLayout의 내부의 텍스트 뷰를 넣고하고있는 ScrollView의 내부에 그 RelativeLayout의를 넣어.

그리고, 설정 로이드 다음 텍스트 뷰 내의

layout_centerInParent = "true"로
관련 문제