2017-11-10 3 views
0

を埋める:GridViewのは次の点を考慮して、列幅に

上記のGridLayoutで
<GridLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:background="@drawable/border" 
    android:paddingTop="10dp" 
    android:paddingBottom="10dp" 
    android:paddingStart="15dp" 
    android:paddingEnd="15dp"> 

    <TextView 
     android:id="@+id/tv_Progress_Level" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:textColor="@color/White" 
     android:layout_row="0" 
     android:layout_column="0" 
     android:text="@string/Progress" 
     android:textStyle="bold" /> 

    <ProgressBar 
     android:id="@+id/pb_Assignment_Progress" 
     style="@android:style/Widget.Holo.ProgressBar.Horizontal" 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:layout_row="0" 
     android:layout_column="1" 
     android:paddingStart="10dp" 
     android:paddingTop="3dp"/> 

</GridLayout> 

、私のプログレスバーは、幅テストのために50%に設定されています。 enter image description here

バーが50%のマークを明確にませです:

しかし、上記の設定で、これが結果です。

はい、これは、実際にグリッドの先頭から最後までスペースを占める塗りつぶしの親を使用したためです。

私はバーの上にwrap_contentを使用してみましたが、それは多くの短いようだ: enter image description here

は、私は、グリッドの残りのスペースを埋めることができます方法はありますか?

fill_parentは残りのスペースを埋めることを意味しないと思われますか?私は間違っていたと思います。その代わり、私はそれだけでそれを解決TextView

+0

私はmatch_parentを試みたが、それは実際に所有しています幅o f全体のgridviewし、2番目の列に私はそれが欲しくない提示します。私はそれが列スペースを取ることだけを望む。 – NewbieCoder

+0

セル?それは私のグリッドレイアウトにどのように実装されていますか? – NewbieCoder

答えて

0

android:layout_width="0dp" 

TO

android:layout_width="fill_parent" 

と次の行を追加します。

android:layout_gravity="fill" 

enter image description here

0

後に残りのスペースを埋めるためにしたい、実際に私はバーは、グリッドの幅を持ってしたくないmatch_parent

の非推奨バージョンです:

<GridLayout 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:paddingBottom="10dp" 
    android:paddingEnd="15dp" 
    android:paddingStart="15dp" 
    android:paddingTop="10dp"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:orientation="horizontal"> 

     <TextView 
      android:id="@+id/tv_Progress_Level" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:text="Progress" 
      android:textColor="@color/white" 
      android:textStyle="bold" /> 

     <ProgressBar 
      android:id="@+id/pb_Assignment_Progress" 
      style="@android:style/Widget.Holo.ProgressBar.Horizontal" 
      android:layout_width="match_parent" 
      android:layout_height="wrap_content" /> 
    </LinearLayout> 


</GridLayout> 

ハッピーコーディング!

次の変更のような単純な
関連する問題