2017-07-09 3 views
0

これは私のコードであるPictureレイアウトの幅をhorizo​​ntalscrollviewの内側に合わせる方法は?

(写真参照)私は、水平方向のLinearLayoutの幅に合わせたいが、それの最後にいくつかの空白がある:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
android:id="@+id/activity_main" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
tools:context="com.example.shahin.testing2.MainActivity"> 
<HorizontalScrollView 
    android:orientation="horizontal" 
    android:layout_width="match_parent" 
    android:layout_height="40px" 
    android:id="@+id/layout"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="match_parent" 
     android:id="@+id/Linear" 
     android:layout_gravity="center_horizontal" 
     android:orientation="horizontal"> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 
     <Button 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" /> 



    </LinearLayout> 

</HorizontalScrollView> 


</LinearLayout> 
activity_main.xml

このコードを変更して最後に空白がないようにするにはどうすればよいですか?

+0

@Peterhddが動作しません –

答えて

0

私は答えを得た、私は親linear_layoutでcenter_horizo​​ntalに重力属性を宣言する必要があります。

関連する問題