2017-07-05 9 views
-3

以下のレイアウトをLinearLayoutを使って構築したいと思います。 enter image description here ConstraintLayoutを使用して作成しましたが、長すぎます。そして今、私はこのレイアウトがLinearLayoutを使ってどのように作成できるのだろうと思っていますか?出来ますか?また、画像には独自のサイズが必要です。なぜなら、match_parentまたはwrap_contentの場合、画像の品質が悪くなるからです。これはLinearLayoutで構築しようとした方法ですが、結果はあまりにも異なっています。それで、私は何をしなければなりませんか?LinearLayoutを使用してこのレイアウトを作成する方法は?

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    xmlns:tools="http://schemas.android.com/tools" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:orientation="vertical" 
    tools:context="com.example.abay.myeleven.MyTeamActivity"> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/attacks" 
     android:orientation="horizontal" 
     android:layout_marginTop="25dp" 
     android:layout_weight="1" 
     > 

     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 

     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 
     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 











    </LinearLayout> 



    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/midfields" 
     android:orientation="horizontal" 
     android:layout_marginTop="25dp" 
     android:layout_weight="1" 
     > 
     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 

     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 
     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 



     </LinearLayout> 

    <LinearLayout 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content" 
     android:id="@+id/defenders" 
     android:orientation="horizontal" 
     android:layout_marginTop="25dp" 
     android:layout_weight="1" 

     > 
     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 

     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 
     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 
     <ImageButton 
      android:layout_width="@dimen/player_width" 
      android:layout_height="@dimen/player_height" 
      android:src="@drawable/player_default" 
      android:layout_weight="1" 
      android:background="#FFF" 
      /> 


    </LinearLayout> 



    <ImageButton 
     android:layout_width="@dimen/player_width" 
     android:layout_height="@dimen/player_height" 
     android:src="@drawable/player_default" 
     android:layout_weight="1" 
     android:background="#FFF" 
     android:layout_gravity="center" 
     /> 





</LinearLayout> 

答えて

0

ただ、これらのグループの周りに別のLinearLayoutImageViewのためのいくつかのパディングを追加します。

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:app="http://schemas.android.com/apk/res-auto" 
xmlns:tools="http://schemas.android.com/tools" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:orientation="vertical" 
tools:context="com.example.abay.myeleven.MyTeamActivity"> 

<LinearLayout 
    android:id="@+id/attacks" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="25dp" 
    android:orientation="vertical"> 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center_vertical" 
     android:orientation="horizontal"> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

    </LinearLayout> 
</LinearLayout> 


<LinearLayout 
    android:id="@+id/midfields" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="25dp" 
    android:orientation="vertical" 

    > 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center_vertical" 
     android:orientation="horizontal"> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 


    </LinearLayout> 
</LinearLayout> 

<LinearLayout 
    android:id="@+id/defenders" 
    android:layout_width="match_parent" 
    android:layout_height="wrap_content" 
    android:layout_marginTop="25dp" 
    android:orientation="vertical" 


    > 

    <LinearLayout 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_gravity="center" 
     android:gravity="center_vertical" 
     android:orientation="horizontal"> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

     <ImageButton 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:background="#FFF" 
      android:paddingLeft="10dp" 
      android:paddingRight="10dp" 
      android:src="@drawable/player_default" /> 

    </LinearLayout> 
</LinearLayout> 


<ImageButton 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_gravity="center" 
    android:layout_marginTop="25dp" 
    android:background="#FFF" 
    android:paddingLeft="10dp" 
    android:paddingRight="10dp" 
    android:src="@drawable/player_default" /> 


</LinearLayout> 
関連する問題