필자는 아래 xml에 표시된 버튼 중 하나를 클릭하면 버튼의 텍스트가 한 줄 아래로 점프된다는 문제가 있습니다. 따라서 버튼이 1 줄이면 텍스트가 표시되지 않습니다. 버튼이 2 라인 인 경우 버튼의 버튼에 첫 번째 라인 만 표시됩니다.안드로이드 버튼 텍스트가 움직입니다.
onClick 메서드의 아무 것도 레이아웃을 변경하지 않습니다.
내가 버튼에 layout_width가 wrap_content로 변경하면 지금, 모든 것이 (When changing textview, the text on a button below the textview moves down. Help!에서 생각이있어) 잘 작동
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:id="@+id/layout_main">
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
.. a few other layouts and controls that works fine
<TableLayout
android:id="@+id/tableLayout276"
android:layout_width="match_parent"
android:layout_height="wrap_content" >
<TableRow
android:id="@+id/TableRow10"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="left"
android:gravity="center"
android:orientation="vertical" >
<Button
android:id="@+id/BtnRet"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="Ret"
android:gravity="center"
android:textSize="18dp" />
<Button
android:id="@+id/BtnVisningsType"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="Decimaltal"
android:gravity="center"
android:textSize="18dp" />
<Button
android:id="@+id/BtnFunktioner"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:text="Funktioner"
android:gravity="center"
android:textSize="18dp" />
</TableRow>
</TableLayout>
.. a few other layouts and controls that works fine
</LinearLayout>
</ScrollView>
</LinearLayout>
을 heres XML - 지금 obviusly 같은 폭을 해달라고 버튼을 제외하고, 그리고 그것은 더러워 보입니다.
왜 이런 일이 발생하는지, 그리고 텍스트를 보관하고 단추의 크기를 결정할 수있는 방법에 대해 알 수 있습니까?
완전히 동의하십시오. 예를 들어 하드 코딩 된보기 크기를 사용하지 않으려 고합니다. android : layout_width = "120dp" –
Ive에게이 질문이 몇 가지 있습니다. 첫 번째 : 당신의 제안은 선형 뷰입니다. "weigthsum"라인이있는 선형 레이아웃을 사용하면 버튼을 아래쪽 대신에 옆으로 조정할 수 있습니다. 그런 종류의 테이블 레이아웃을 망칠 수 있습니까? – user1285334
두 번째 : 패딩/여백을 사용하여 단추의 크기를 조정하면 단추의 크기가 변하지 않습니까? 텍스트를 변경하면 어떻게됩니까? 나는 버튼들이 서로 같은 크기가되도록하고, 무슨 일이 일어나더라도 그 크기를 유지한다. (물론 텍스트가 길어지면 wrap_content 높이의 두 번째 줄이 생깁니다.하지만 괜찮습니다.) – user1285334