programing

선형 레이아웃의 너비에 걸쳐 버튼을 고르게 분배할 수 있습니까?

codeshow 2023. 8. 10. 21:43
반응형

선형 레이아웃의 너비에 걸쳐 버튼을 고르게 분배할 수 있습니까?

나는 있습니다LinearLayout(수평 방향) 버튼이 3개 포함되어 있습니다.나는 3개의 버튼이 고정된 폭을 가지고 있고, 폭을 가로질러 고르게 분포되어 있기를 원합니다.LinearLayout.

저는 이것의 중력을 설정함으로써 이것을 관리할 수 있습니다.LinearLayout단추의 가운데를 맞춘 다음 채우기를 조정하지만, 이는 고정된 너비에 대해 작동하며 다른 장치나 방향에 대해서는 작동하지 않습니다.

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

    <Button
        android:id="@+id/btnOne"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="120dp" />

    <Button
        android:id="@+id/btnTwo"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="120dp" />


    <Button
        android:id="@+id/btnThree"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:width="120dp" />
</LinearLayout>

설정한 경우, Fedj의 답변을 확장합니다.layout_width0dp 설합니다를 합니다.layout_weight각 버튼에서 1까지, 사용 가능한 너비는 버튼 간에 동일하게 공유됩니다.

단추의 크기를 조정하지 않고 단추 사이의 간격(모든 단추 사이의 간격을 조정함)을 조정하려면 단추 사이의 공간을 채우는 가중치="1" 보기를 사용할 수 있습니다.

    <Space
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" >
    </Space>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:background="@null"
        android:gravity="center_horizontal|center_vertical"
        android:src="@drawable/tars_active" />

    <Space
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" >
    </Space>

    <ImageButton
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:adjustViewBounds="true"
        android:background="@null"
        android:gravity="center_horizontal|center_vertical"
        android:src="@drawable/videos_active" />

    <Space
        android:layout_width="0dp"
        android:layout_height="1dp"
        android:layout_weight="1" >
    </Space>

이를 위한 최신 솔루션은 Flexbox입니다.

<com.google.android.flexbox.FlexboxLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    app:justifyContent="space_around"> <!-- or "space_between", "space_evenly" -->

    <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:width="120dp" />

    <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:width="120dp" />

    <Button 
        android:layout_width="wrap_content" 
        android:layout_height="wrap_content" 
        android:width="120dp" />
</com.google.android.flexbox.FlexboxLayout>

를 반드시 해 주세요.implementation 'com.google.android:flexbox:2.0.0'

Flexbox훨씬 더 강력합니다; 그것은 좋은 보완책입니다.ConstraintLayout이것은 더 많은 것을 배울 수 있는 훌륭한 자료입니다.

Difference between space_around, space_between, and space_evenly

두 가지를 모두 제공하여 이 작업을 수행할 수 있습니다.Viewlayout_width0dp a 리고a.layout_weight1:

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

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

    <TextView
        android:layout_width="0dp"
        android:text="example text"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

</LinearLayout>

Android layout_weight의 작동 방식은 다음과 같습니다.

  • 먼저, 보기가 일반적으로 사용할 크기를 확인하고 이 공간을 예약합니다.
  • 이 째둘, 레웃이아인 match_parent그러면 그것은 남은 공간을 다음의 비율로 나눌 것입니다.layout_weight그러므로 만약 당신이 뷰를 제공했다면.layout_weight="2"그리고.layout_weight="1"결과 비율은 2 대 1이 됩니다. 즉, 첫 번째 보기는 남은 공간의 2/3을 얻고 다른 보기는 1/3을 얻습니다.

그래서 만약 당신이 그것을 준다면,layout_width0dp두 보기 모두 공간이 할당되지 않았기 때문에 첫 번째 단계에는 추가된 의미가 없습니다.합니다. 각각의 그리두점각만각공결간정다니합을의이째번고▁each▁space▁the▁thenViewgets, gets를 것, 라서제공따.View비율에 ! s 에 따 지 정 한 공 간 라 비 율 ! 간공

반대의 예를 제시하여 공간이 동일하게 분할되는 이유를 설명합니다.아래 코드는 다음과 같은 결과를 초래할 수 있습니다.example text가 제이 너가다 다큽니다보다 .0dp 있기때문에가 있기 입니다.wrap_content대신 텍스트가 공간을 차지하기 때문에 100% 미만으로 나누기 위해 남은 여유 공간을 만듭니다.결과적으로 그들은 50%의 사용 가능한 공간을 얻지만 텍스트는 이미 약간의 공간을 차지했습니다.TextView전체 공간의 50% 이상을 차지합니다.

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

    <Button
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

    <TextView
        android:layout_width="wrap_content"
        android:text="example text"
        android:layout_height="wrap_content"
        android:layout_weight="1"/>

</LinearLayout>

다음과 같이 사용하시면 됩니다.

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_marginTop="15dp">
    <Space
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Save"/>
    <Space
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Reset"/>
    <Space
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>
    <Button
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="cancel"/>
    <Space
        android:layout_weight="1"
        android:layout_height="wrap_content"
        android:layout_width="wrap_content"/>
</LinearLayout>

안드로이드:layout_weight 속성을 살펴봐야 합니다.

정확히 3개의 버튼이 있고 외부 버튼이 왼쪽과 오른쪽에 정렬되어 있어도 괜찮거나 계획된 경우 많은 경우에 오버헤드가 적은 상대 레이아웃을 시도할 수 있습니다.

사용할 수 있습니다.layout_alignParentBottom모든 단추를 레이아웃의 맨 아래에 정렬합니다.layout_alignParentLeft and Right 및 외부 버및튼 및▁the.layout_centerHorizontal가운데 단추로

다른 방향과 화면 크기에서 잘 작동합니다.

다음을 사용해야 합니다.android:weightSum속성 선형 레이아웃.선형 레이아웃에 가중치 합계를 레이아웃 내부의 버튼 수와 동일하게 지정한 다음 설정android:layout_weight="1"합니다.android:layout_width="0dp"또한 패딩과 레이아웃 여백을 사용하여 레이아웃 스타일을 지정할 수 있습니다.

<LinearLayout android:id="@+id/LinearLayout01"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:gravity="center"
    android:weightSum="3">
    
    <Button
        android:id="@+id/btnOne"
        android:layout_width="0dp"
        android:text="1"
        android:layout_height="wrap_content"
        android:width="120dip"
        android:layout_weight="1"
        android:layout_margin="15dp" 
        />
    
    <Button
        android:id="@+id/btnTwo"
        android:text="2"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:width="120dip"
        android:layout_weight="1"
        android:layout_margin="15dp" />

    <Button
        android:id="@+id/btnThree"
        android:text="3"
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:width="120dip"
        android:layout_weight="1"
        android:layout_margin="15dp" />

</LinearLayout>

그것을 동적으로 하기 위해서.

void initiate(Context context){
    LinearLayout parent = new LinearLayout(context);

    parent.setLayoutParams(new LinearLayout.LayoutParams(LinearLayout.LayoutParams.MATCH_PARENT, LinearLayout.LayoutParams.WRAP_CONTENT));
    parent.setWeightSum(3);
    parent.setOrientation(LinearLayout.HORIZONTAL);

    AppCompatButton button1 = new AppCompatButton(context);
    button1.setLayoutParams(new LinearLayout.LayoutParams(0 ,LinearLayout.LayoutParams.WRAP_CONTENT,1.0f));

    AppCompatButton button2 = new AppCompatButton(context);
    button2.setLayoutParams(new LinearLayout.LayoutParams(0 ,LinearLayout.LayoutParams.WRAP_CONTENT,1.0f));

    AppCompatButton button3 = new AppCompatButton(context);
    button3.setLayoutParams(new LinearLayout.LayoutParams(0 ,LinearLayout.LayoutParams.WRAP_CONTENT,1.0f));
    
    parent.addView(button1);
    parent.addView(button2);
    parent.addView(button3);

}

linearLayout무게를 주는 대신에Button를 그자로체, 무를설니다합정으로 합니다.<Space>보기 이것은 확장되지 않습니다.Button.

    <?xml version="1.0" encoding="utf-8"?>
    <androidx.constraintlayout.widget.ConstraintLayout 
    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"
    tools:context=".MainActivity">

    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="horizontal"
        android:weightSum="4"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintHorizontal_bias="0.5"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent"
        app:layout_constraintVertical_bias="0.955">

        <Space
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <Button
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:background="@drawable/ic_baseline_arrow_back_24" />

        <Space
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/captureButton"
            android:layout_width="72dp"
            android:layout_height="72dp"
            android:background="@drawable/ic_round_camera_24" />

        <Space
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />

        <Button
            android:id="@+id/cameraChangerBtn"
            android:layout_width="48dp"
            android:layout_height="48dp"
            android:background="@drawable/ic_round_switch_camera_24" />

        <Space
            android:layout_width="0dp"
            android:layout_height="0dp"
            android:layout_weight="1" />
    </LinearLayout>

    </androidx.constraintlayout.widget.ConstraintLayout>

4를 사용하고 있기 때문에<Space>설정합니다.android:weightSum="4"linear layout또한 다음과 같은 결과가 있습니다.

layout preview

수평 선형 레이아웃에서 두 개의 버튼을 고르게 간격을 두기 위해 3개의 선형 레이아웃 객체를 사용하여 크기가 자동으로 조정되는 공간 역할을 했습니다.이러한 선형 레이아웃 개체를 다음과 같이 배치했습니다.

[] 버튼1 [] 버튼2 []

([]는 간격띄우기에 사용되는 LinearLayout 객체를 나타냅니다)

그런 다음 각 [] 선형 레이아웃 개체의 가중치를 1로 설정하면 단추의 간격이 균일해집니다.

이게 도움이 되길 바랍니다.

이를 위해 사용자 정의 View Distribute Layout을 만들었습니다.

선형 레이아웃의 weightSum 속성을 사용하는 것이 좋습니다.

android:weightSum="3"에 LinearLayout의 xml 파일로 합니다.android:layout_weight="1"버튼을 누르면 3개의 버튼이 균등하게 분배됩니다.

이렇게 하면 컨테이너 내부에 추가된 모든 버튼에 할당할 수 있으며, 수평 방향을 정의하는 데 매우 중요합니다.

    int buttons = 5;

    RadioGroup rgp = (RadioGroup) findViewById(R.id.radio_group);

    rgp.setOrientation(LinearLayout.HORIZONTAL);

    for (int i = 1; i <= buttons; i++) {
        RadioButton rbn = new RadioButton(this);         
        rbn.setId(1 + 1000);
        rbn.setText("RadioButton" + i);
        //Adding weight
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, 1f);
        rbn.setLayoutParams(params);
        rgp.addView(rbn);
    }

결과적으로 장치에 이러한 기능을 추가할 수 있습니다.

enter image description here

장치를 회전하더라도 각 버튼에 정의된 요소가 용기를 따라 균일하게 분배될 수 있습니다.

enter image description here

은 가장좋방은을 하는 것입니다.TableLayout와 함께android:layout_width="match_parent"에는 및열사용을 합니다.android:layout_weight="1"모든 열에 대해

layout_을 사용한 위의 답변들은 저에게 효과가 없었지만, 다음과 같은 답변들이 효과가 있었습니다.

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:layout_weight="0.1"
    android:layout_gravity="center_horizontal"
    >

    <android.support.design.widget.FloatingActionButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
       />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:layout_marginLeft="40dp"
        android:layout_marginStart="40dp"/>

    <android.support.design.widget.FloatingActionButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:layout_marginLeft="40dp"
        android:layout_marginStart="40dp"
        />

    <android.support.design.widget.FloatingActionButton
        android:layout_width="50dp"
        android:layout_height="50dp"
        android:layout_gravity="center"
        android:layout_marginLeft="40dp"
        android:layout_marginStart="40dp"/>

</LinearLayout>

이게 화면에 보이는 거예요.

enter image description here

무엇보다 정답은 맞지만, 눈에 보이는 기능과 사라진 기능이 필요한 경우 이 실용적인 방법이 잘 작동할 것입니다.

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

        <Button
            android:id="@+id/btnOne"
            android:layout_width="120dp"
            android:layout_height="match_parent"></Button>

        <Button
            android:id="@+id/btnTwo"
            android:layout_width="120dp"
            android:layout_height="match_parent"></Button>


        <Button
            android:id="@+id/btnThree"
            android:layout_width="120dp"
            android:layout_height="match_parent"></Button>
    </LinearLayout>



 float width=CommonUtills.getScreenWidth(activity);
            int cardWidth=(int)CommonUtills.convertDpToPixel (((width)/3),activity);

LinearLayout.LayoutParams params =
                new LinearLayout.LayoutParams(width,
                        LinearLayout.LayoutParams.MATCH_PARENT);

btnOne.setLayoutParams(params);
btnTwo.setLayoutParams(params);
btnThree.setLayoutParams(params);

public class CommonUtills {
public static float getScreenWidth(Context context) {
        float width = (float) 360.0;
        DisplayMetrics displayMetrics = context.getResources().getDisplayMetrics();
        width = displayMetrics.widthPixels / displayMetrics.density;
        return width;
    }
}

균등하게 가중치가진 아동

각 어린이가 화면에서 동일한 공간을 사용하는 선형 레이아웃을 만들려면 각 보기의 Android:layout_height를 "0dp"(수직 레이아웃의 경우)로 설정하고 각 보기의 Android:layout_width를 "0dp"(수평 레이아웃의 경우)로 설정합니다.그런 다음 각 보기의 Android:layout_weight를 "1"로 설정합니다.

이 이이작위는에서 LinearLayout - " ": "의 속성 합니다.android:layout_width그리고.android:layout_height과 같아야 ."match_parent"...

이것을 사용할 수 있습니다. 이해하기가 너무 쉽습니다. by https://timeout.https://timeout.html

<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="horizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
    android:text="Tom"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textSize="24sp" />

<TextView
    android:text="Tim"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textSize="24sp" />

<TextView
    android:text="Todd"
    android:layout_width="0dp"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:textSize="24sp" />

</LinearLayout>
<LinearLayout
    xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="match_parent"
    android:layout_height="match_parent">

    <TextView
        android:text="Tom"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="24sp" 
        android:layout_weight="3"/>

    <TextView
        android:text="Tim"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="24sp"
        android:layout_weight="3"/>

    <TextView
        android:text="Todd"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:textSize="24sp" 
        android:layout_weight="3"/>

</LinearLayout>

원 안에서, 톰, 팀, 그리고 토드는 3센티미터로 가정됩니다.터치다운 화면으로 하려면 Tom과 Tim이 1cm라고 가정하면 가상을 결합하지만 2D 평면은 하단에 있습니다.이것은 화면에 표시됩니다.

가장 쉽고 빠른 방법은 다음과 같이 텍스트 속성이 비어 있는 TextView를 추가하는 것입니다.

android:text=""

배경색은 선형 레이아웃에서 동일해야 합니다. 그런 다음 패딩 속성을 사용할 수 있습니다.

android:paddingBottom="250dp"

필요한 것은 무엇이든.여기 예가 있습니다.

3개의 버튼이 고정된 너비를 가지며 레이아웃 너비에 걸쳐 고르게 분포되도록 하려면...제약 조건Layout을 사용하는 것이 어떻습니까?

<androidx.constraintlayout.widget.ConstraintLayout 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">

        <Button
            android:id="@+id/btnOne"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="120dip"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toStartOf="parent"
            app:layout_constraintEnd_toStartOf="@id/btnTwo">
            
        </Button>

        <Button
            android:id="@+id/btnTwo"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="120dip"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintEnd_toStartOf="@id/btnThree"
            app:layout_constraintStart_toEndOf="@id/btnOne"></Button>


        <Button
            android:id="@+id/btnThree"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:width="120dip"
            app:layout_constraintTop_toTopOf="parent"
            app:layout_constraintBottom_toBottomOf="parent"
            app:layout_constraintStart_toEndOf="@id/btnTwo"
            app:layout_constraintEnd_toEndOf="parent">
            
        </Button>

</androidx.constraintlayout.widget.ConstraintLayout>

너비와 be는 레이아웃의 너비에 걸쳐 고르게 분포됩니다.제약 조건 레이아웃을 사용하지 않는 이유는 무엇입니까?

<androidx.constraintlayout.widget.ConstraintLayout
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">

 <Button android:id="@+id/btnOne" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:width="120dip"
  app:layout_constraintTop_toTopOf="parent"
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintStart_toStartOf="parent"
  app:layout_constraintEnd_toStartOf="@id/btnTwo">
 </Button> 

 <Button android:id="@+id/btnTwo" android:layout_width="wrap_content"
  android:layout_height="wrap_content" android:width="120dip" 
  app:layout_constraintTop_toTopOf="parent" 
  app:layout_constraintBottom_toBottomOf="parent"
  app:layout_constraintEnd_toStartOf="@id/btnThree"
  app:layout_constraintStart_toEndOf="@id/btnOne"></Button> <Button 
  android:id="@+id/btnThree" android:layout_width="wrap_content"    
  android:layout_height="wrap_content" android:width="120dip" 
  app:layout_constraintTop_toTopOf="parent" 
  app:layout_constraintBottom_toBottomOf="parent" 
  app:layout_constraintStart_toEndOf="@id/btnTwo" 
  app:layout_constraintEnd_toEndOf="parent"> 
 </Button>

</androidx.constraintlayout.widget.ConstraintLayout>```

또 다른 해결책은 제약 조건 레이아웃 내부에 단추를 중첩하고 이러한 방식으로 단추의 간격을 동일하게 지정하는 것입니다.버튼이 레이아웃에서 동일한 간격으로 배치되도록 제약 조건을 올바르게 설정해야 합니다.

선형 레이아웃을 루트로 사용하는 경우에도 작동합니다.

<androidx.constraintlayout.widget.ConstraintLayout
    android:layout_width="match_parent"
    android:layout_height="wrap_content">

    <androidx.appcompat.widget.AppCompatButton
        android:id="@+id/deleteButton"
        android:layout_width="wrap_content"
        android:layout_height="64dp"
        android:layout_marginStart="8dp"
        android:layout_marginTop="8dp"
        android:layout_marginBottom="8dp"
        android:text="asdf"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintEnd_toStartOf="@+id/shareButton"
        app:layout_constraintStart_toStartOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

    <androidx.appcompat.widget.AppCompatButton
        android:id="@+id/shareButton"
        android:layout_width="wrap_content"
        android:layout_height="64dp"

        android:layout_marginStart="8dp"
        android:layout_marginEnd="8dp"
        android:text="sdsfa"
        app:layout_constraintEnd_toEndOf="parent"
        app:layout_constraintStart_toEndOf="@+id/deleteButton"
        app:layout_constraintTop_toTopOf="@+id/deleteButton" />
</androidx.constraintlayout.widget.ConstraintLayout>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="wrap_content"
android:layout_height="wrap_content">

<TextView
    android:text="Tom"
    android:layout_width="wrap_content"
    android:layout_height="200dp"
    android:textSize="24sp" />

<TextView
    android:text="Tim"
    android:layout_width="wrap_content"
    android:layout_height="200dp"
    android:textSize="24sp" />

<TextView
    android:text="Todd"
    android:layout_width="wrap_content"
    android:layout_height="200dp"
    android:textSize="24sp" />

언급URL : https://stackoverflow.com/questions/3470420/is-it-possible-to-evenly-distribute-buttons-across-the-width-of-a-linearlayout

반응형