2010-12-03 9 views
0

I 안드로이드 텍스트 뷰 위치

alt text

지금은에 오신 것을 환영합니다 텍스트를 추가 할 필요가

로 출력을 제공하는 다음과 같은 레이아웃을

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

    <Button android:id="@+id/mq_categories" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="Browse Quiz Categories" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 
    <Button android:id="@+id/mq_random" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="Enter Random Quiz" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 
    <Button android:id="@+id/mq_profile" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="My Profile" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 

</LinearLayout> 

했습니다 화면의 상단 부분

이렇게 텍스트보기를 추가하면 시작 텍스트 만 표시됩니다 그리고 아무 버튼도없고 아무 스크롤

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

    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/mg_userinfo" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:text="Welcome" 
     android:gravity="center" /> 

    <Button android:id="@+id/mq_categories" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="Browse Quiz Categories" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 
    <Button android:id="@+id/mq_random" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="Enter Random Quiz" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 
    <Button android:id="@+id/mq_profile" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="My Profile" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 


</LinearLayout> 
아래 시도 환영 텍스트가 버튼의 하단에 표시됩니다 배치하지만, 버튼은 화면 상단으로 이동있어

alt text

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

    <Button android:id="@+id/mq_categories" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="Browse Quiz Categories" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 
    <Button android:id="@+id/mq_random" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="Enter Random Quiz" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 
    <Button android:id="@+id/mq_profile" android:layout_width="fill_parent" 
     android:layout_height="wrap_content" android:layout_margin="5dp" 
     android:text="My Profile" android:textColor="#EDFF99" 
     android:background="@drawable/custom_button" /> 

    <TextView xmlns:android="http://schemas.android.com/apk/res/android" 
     android:id="@+id/mg_userinfo" android:layout_width="fill_parent" 
     android:layout_height="fill_parent" android:text="Welcome" 
     android:gravity="center" /> 

</LinearLayout> 

alt text

환영 메시지를 추가하려면 어떻게해야합니까? 중앙에 단추가있는 스크린?

답변

1

변경 텍스트 뷰의 다음 특성 :

android:layout_width="wrap_content" 
android:layout_height="wrap_content" 

단추 위에 텍스트 뷰를 놓습니다.

1

당신이

안드로이드 사용하는 경우 : layout_height = "fill_parent"를

안드로이드가 전체 화면으로 채울 것입니다. 당신이

안드로이드 사용할 수 있습니다 : layout_height = "20DIP"

또는

안드로이드 : layout_height를 = "20 픽셀"

+2

px의 사용은 권장되지 않습니다. 다양한 화면 밀도의 장치에서 제대로 확장되지 않습니다. 항상 dip이나 dp를 사용하십시오 (둘 다 동일 함). – Mudassir

관련 문제