2016-05-27 2 views
0

全幅を取っていない。これは私のfooterviewである相続人は私がリストビューFooterview

View footerView1 = View.inflate(mContext, R.layout.layout_footerview1, null); 
     listView1.addFooterView(footerView1); 

私のListView footerviewを膨張させるのですかfooterView、すなわちボタンがmatch_parentとして幅を取っていない

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:weightSum="1"> 

    <Button 
     android:id="@+id/button_add_location1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/margin_top_10" 
     android:layout_weight="1" 
     android:text="+ Add more location" 
     android:textColor="@color/grey3" 
     android:textSize="@dimen/size_15" /> 

</LinearLayout> 

むしろそれがあります幅をwrap_contentにします。

私の結果を守るために私を助けてください。前もって感謝します。

+0

あなたはLinearLayout' 'で単一のビューの重みを使用している理由を使用fill_parent –

+2

ボタンのために単に 'match_parent'を使用してください。 –

答えて

0
<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:custom="http://schemas.android.com/apk/res-auto" 
    android:layout_width="fill_parent" 
    android:layout_height="match_parent" 
    android:orientation="horizontal" 
    android:weightSum="1"> 

    <Button 
     android:id="@+id/button_add_location1" 
     android:layout_width="0dp" 
     android:layout_height="wrap_content" 
     android:layout_marginTop="@dimen/margin_top_10" 
     android:layout_weight="1" 
     android:text="+ Add more location" 
     android:textColor="@color/grey3" 
     android:textSize="@dimen/size_15" /> 

</LinearLayout> 
+0

私もこれを使ってみましたが、動作しません。とにかく、私は問題を解決した、私はカスタムリストビューを使用していた。カスタムlistviewのコードを深く見て、その高さと幅がコンテンツをラップするように設定されていることがわかりました。ちょうどその幅のサイズをmatch_parentに変更しました。 –

+0

put u rリストビューコード –

0

あなたはいくつかのプロパティなしにしてみてください、と
セットListViewの高さと幅fill_parent必要があります。
android:weightSum="1"などのなど

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

    <Button 
     android:id="@+id/button_add_location1" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:text="+ Add more location"/> 

</LinearLayout> 

まだあなたはJavaのようにパディングを設定してみてください動作しない場合..

View footer = LayoutInflater.from(this).inflate(R.layout.footer_button, 
      null); 
    footer.setPadding(100, 0, 100, 0);//first is for left and secon 100 for right. 
+0

これも使ってみましたが、うまくいきません。 –

+0

更新された回答。 –

+0

問題を解決しました。私はカスタムリストビューを使用していました。カスタムlistviewのコードを深く見て、その高さと幅がコンテンツをラップするように設定されていることがわかりました。ちょうどその幅のサイズをmatch_parentに変更しました。ソリューションに感謝します。 –