2017-01-24 7 views
1

を取っていません。私のコードをチェックして助けてください。リニアレイアウト要素は、私は私はそれに重みを追加し、それが画面全体を取るためにのためにしようとすると、いくつかのエラーを持つ別のLinearLayoutの小さなのLinearLayoutを持って画面全体

<LinearLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 

    android:orientation="horizontal" 

    android:id="@+id/linear_layout_two" 
    android:layout_below="@+id/linear_layout_one" 
    android:layout_alignParentLeft="true" 
    android:layout_alignParentStart="true"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="60dp" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="25dp" 
      android:textColor="#3193b9" 
      android:text="99.3%" 
      android:layout_weight="1" 
      android:id="@+id/goals_accuracy"/> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="10dp" 
      android:gravity="center" 
      android:text="Goals accuracy" 
      android:layout_weight="1" 
      android:id="@+id/goals_accuracy_2"/> 

    </LinearLayout> 


    <ImageView 
     android:layout_width="0dp" 
     android:layout_height="60dp" 
     android:src="@drawable/the_vertical" 

     android:id="@+id/imageView8" /> 


    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="60dp" 
     android:orientation="vertical"> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="25dp" 
      android:textColor="#3193b9" 
      android:text="10:30hr" 
      android:gravity="center" 
      android:layout_weight="1" 
      android:id="@+id/total_time_on_ice"/> 

     <TextView 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:textSize="10dp" 
      android:text="Total time on ice" 
      android:gravity="center" 
      android:layout_weight="1" 
      android:id="@+id/total_time_on_ice_2"/> 

    </LinearLayout> 
</LinearLayout> 

私はそれに重みを追加しようとしたが、それは仕事をdidntの、私はそれを削除しました。私は、幅を0に設定し、ウェイトを1に設定する必要があることは知っていますが、ネストされたレイアウトで動作させる方法を混乱させています。しかし、私は...

+0

を簡素化することができますか? – firegloves

+0

うん、すべてのレイアウト内のすべてのものがTHWに画面の幅全体を埋めるためにも同様に、これらの2つのレイアウト間でImageViewのは、ちょうど縦線画像 –

答えて

0

あなたのファースト・LinearLayout

短い説明に右の境界線を描画する背景を追加し、この

<LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal" 
     android:id="@+id/linear_layout_two" 
     android:layout_below="@+id/linear_layout_one" 
     android:layout_alignParentLeft="true" 
     android:layout_alignParentStart="true"> 

    <LinearLayout 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="60dp" 
      android:orientation="vertical" 
      > 

     <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:textSize="25dp" 
       android:textColor="#3193b9" 
       android:text="99.3%" 
       android:layout_weight="1" 
       android:id="@+id/goals_accuracy"/> 

     <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:textSize="10dp" 
       android:gravity="center" 
       android:text="Goals accuracy" 
       android:layout_weight="1" 
       android:id="@+id/goals_accuracy_2"/> 

    </LinearLayout> 

    <LinearLayout 
      android:layout_width="0dp" 
      android:layout_weight="1" 
      android:layout_height="60dp" 
      android:orientation="vertical"> 

     <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:textSize="25dp" 
       android:textColor="#3193b9" 
       android:text="10:30hr" 
       android:gravity="center" 
       android:layout_weight="1" 
       android:id="@+id/total_time_on_ice"/> 

     <TextView 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:textSize="10dp" 
       android:text="Total time on ice" 
       android:gravity="center" 
       android:layout_weight="1" 
       android:id="@+id/total_time_on_ice_2"/> 

    </LinearLayout> 
</LinearLayout> 

私が落ちてきたImageViewのを試してみてくださいそれで、彼らはそれぞれの半分の親の幅を持っています。そして、width = 0dpを追加しました。これは、水平の親LinearLayoutを持つため、0の幅に設定する必要があります。代わりに

ImageViewのが有用ではありません、私が説明したように、あなたは国境目標を達成することができます。この方法によって、あなたはまた、あなたの問題はあなたの2のサブのLinearLayoutは全体の親幅を取らないということです、あなたのxml

+0

それは作品!!あなたがしたことを説明してもらえますか? –

+0

私の回答を編集しました – firegloves

0

単一のLinearLayoutに仕事を作ることができたいくつかの注意事項:

  • なぜあなたImageViewの要素は、0幅ですか? android:layout_weight="1"を持つ
  • のTextView要素は、それはあなたの問題を解決する必要があります0高さ

を持つ必要があります。

私は等しいのLinearLayoutそれぞれに割り当てられています

+0

である私はstackoverflowの上で答えを読んでみましたが、それはかなりの仕事をdidntの:/ –

関連する問題