2016-08-14 7 views
-1

以下のコードをアンドロイドスタジオで実行しても、私には望ましい結果が得られません。どうすればよいですか?私は、3つのTextViewsがデバイスの画面に垂直に均等に配置されることを望みます。線形レイアウトの等間隔の垂直スペーシングが機能しない

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

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:text="Debanshu" 
    android:textSize="24sp"/> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:text="Chakraborty" 
    android:textSize="24sp" 
    android:layout_weight="1" /> 

<TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:text="Voltas" 
     android:textSize="24sp" 
     android:layout_weight="1"/> 

</LinearLayout> 
+0

。ありがとうございます。今働いている。ちょうど学び始めました。 – user185995

+0

スクリーンショットを使用すると、何が間違っているのが簡単になります。 –

答えて

0

私はあなたがこの(ちょうどそれの楽しみのための追加の重力を)したいと考えている:wrap_contentその作業に等しい高LinearLayoutあなたとして

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

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:layout_weight="1" 
    android:text="Debanshu" 
    android:gravity="center" 
    android:textSize="24sp"/> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="0dp" 
    android:text="Chakraborty" 
    android:textSize="24sp" 
    android:gravity="center" 
    android:layout_weight="1" /> 

<TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:text="Voltas" 
     android:textSize="24sp" 
     android:gravity="center" 
     android:layout_weight="1"/> 

</LinearLayout> 
0

が、高ラッピングビューとして使用すると、目的のビューを取得されていませんmatch_parent

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

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:layout_weight="1" 
     android:text="Debanshu" 
     android:textSize="24sp"/> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:text="Chakraborty" 
     android:textSize="24sp" 
     android:layout_weight="1" /> 

    <TextView 
     android:layout_width="match_parent" 
     android:layout_height="0dp" 
     android:text="Voltas" 
     android:textSize="24sp" 
     android:layout_weight="1"/> 

</LinearLayout> 
LinearLayout高さを等しくする以下

試してみます

+1

ありがとうございます。今それは働いている – user185995

0

あなたは私のために

が楽しむ

<?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"> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_weight="1" 
    android:text="Debanshu" 
    android:background="#ffa905" 
    android:textSize="24sp"/> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Chakraborty" 
    android:textSize="24sp" 
    android:background="#ffffff" 
    android:layout_weight="1" /> 

<TextView 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:text="Voltas" 
    android:textSize="24sp" 
    android:background="#008000" 
    android:layout_weight="1"/> 

をこの作業を試すことができます!

関連する問題