Android 앱에서 원하는 GUI 레이아웃 결과를 얻는 데 어려움이 있습니다.
내가 원하는 것에 대한 간단한 설명 :
GUI는 2 개의 TextView와 4 개의 버튼을 포함합니다.
네 개의 버튼은 모두 같은 행에 수평으로 배치되어 화면 오른쪽 하단에 고정됩니다.
두 개의 TextView 중 첫 번째는 화면 맨 위에서 시작하는 것입니다. 텍스트 내용은 한 줄에서 수십 줄까지 다양합니다. 스크롤없이 화면에 표시되는 것보다 더 많습니다. 따라서 때로는 모든 내용을 보려면 스크롤이 필요합니다. 스크롤이 필요한 경우에도 버튼은 스크롤에 참여하지 않습니다. 항상 화면 오른쪽 하단의 단일 행에 고정되어 있어야합니다. 스크롤이 필요한 경우 스크롤 텍스트는 항상 버튼 위에 있어야합니다. 버튼은 텍스트를 오버레이하지 않아야합니다.
두 개의 TextView 중 두 번째는 첫 번째 TextView 바로 아래에 나타나며 일반적으로 전체 텍스트 길이에 한두 줄만 추가합니다. 스크롤이 필요한 경우 두 번째 TextView는 첫 번째 TextView와 함께 스크롤하여 항상 첫 번째 TextView 바로 아래에 표시됩니다.
추가 제약 조건에는 가로 및 세로 화면 레이아웃 모두에서 다음 Android 장치 모두에서 레이아웃이보기 좋게 보이도록하는 것이 포함됩니다.
- Android 1.5 API3 QVGA MDPI (320x240) 기기
- Android 1.5 API3 HVGA MDPI 기기
- Android 1.6 API4 QVGA LDPI 기기
- Android 2.3 API10 WVGA800 기기
- 위의 기기 사이에 화면이있는 모든 것
내일과 같이 다른 날 태블릿에 대해 걱정할 것입니다.
-
레이아웃의 다양한 조합을 시도했지만 아직 목표에 근접한 것은 없습니다.
(일부 시도한 레이아웃 조합으로 RelativeLayout을 사용하여 화면 왼쪽 하단의 버튼을 수정할 수는 있지만 스콜 링 텍스트로 시도하는 모든 결과는 항상 버튼 뒤에서 스크롤되는 텍스트로 나타납니다-버튼 오버레이 버튼을 오른쪽 아래에 맞추는 방법을 찾지 못했습니다.)
내가 이것을 알아내는 데 도움을 준 사람이라면, 아래의 레이아웃 예제 xml은 대화의 시작점이지만, 다음 스크린 샷에서 보여지는 것처럼 동일한 레이아웃 예제 xml을 사용하여 생성 된 목표 결과를 확실히 달성하지 못합니다. . (일부 스크린 샷은 같은 문제를 보여 주지만, 내가 다른 화면을보고있는 위치를 표시하는 데 도움이됩니다.)
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text View 1. Text varies from a few lines to many more lines than what fits on the screen. Scrolling is necessary to see it all." />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text View 2. Short text entry sits below Text View 1." />
</LinearLayout>
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/button_1"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 1" />
<Button
android:id="@+id/button_2"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 2" />
<Button
android:id="@+id/button_3"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 3" />
<Button
android:id="@+id/button_4"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 4" />
</LinearLayout>
</LinearLayout>
1.5_API3_HVGA_Horizontal_MDPI-short_text :
문제 : 버튼이 화면 오른쪽 아래에 맞춰져야합니다.
-
1.5_API3_HVGA_Vertical_MDPI-short_text :
문제 : 버튼이 화면 오른쪽 아래에 맞춰져야합니다.
-
1.5_API3_QVGA_240x320_MDPI-short_text :
문제 : 4 번째 버튼이 박살났습니다. 필요할 때 줄 바꿈하기 위해 처음 세 개의 버튼에 텍스트를 선호하고 네 번째 버튼을 표시 할 충분한 공간을 남겨 두십시오.
-
1.5_API3_QVGA_320x240_MDPI-short_text :
문제 : 버튼이 화면 오른쪽 아래에 맞춰져야합니다.
-
1.6_API4_QVGA_Horizontal_LDPI-long_text :
문제 : 텍스트가 화면을 거의 채우면 단추 줄이 박살납니다. 버튼 행은 스매시되어서는 안되며 화면 오른쪽 하단에 고정되어 있어야합니다. 텍스트가 버튼 위로 스크롤되어야합니다.
-
1.6_API4_QVGA_Horizontal_LDPI-short_text :
문제 : 버튼이 화면 오른쪽 아래에 맞춰져야합니다.
-
1.6_API4_QVGA_Horizontal_LDPI-very_long_text, 맨 위에 스크롤 막대 :
문제 : 버튼이 화면에 없습니다. 화면 오른쪽 하단에 고정되어 있어야합니다.
-
1.6_API4_QVGA_Horizontal_LDPI-very_long_text, 맨 아래에 스크롤 막대 :
문제 : 텍스트 스크롤바가 맨 아래에 있지만 버튼을 찾을 수있는 곳이 없습니다. 화면 오른쪽 하단에 고정되어 있어야합니다.
-
1.6_API4_QVGA_Vertical_LDPI-short_text :
문제 : 버튼이 화면 오른쪽 아래에 맞춰져야합니다.
-
어떤 조언?
-
추가 정보 : RelativeLayout을 사용하려고 할 때
android:layout_alignParentBottom="true"
를 사용하여 화면 하단의 단추를 수정하십시오
, 내 문제는 스크롤보기의 하단을 버튼의 상단으로 고정하는 방법을 모른다는 것입니다.
android:layout_alignBottom="@id/buttons"
사용
스크롤보기의 하단을 버튼의 하단에 맞추면 버튼이 다음과 같이 텍스트를 오버레이합니다.
-
업데이트 : 버튼 위의 스크롤 텍스트로 버튼을 오른쪽 아래에 고정시키는 문제가 해결되었습니다.
여기까지 작동하는 변경된 레이아웃 XML은 다음과 같습니다 (스크롤링을 보려면 더 많은 텍스트를 텍스트보기 1에 붙여 넣기).
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text View 1. Text varies from a few lines to many more lines than what fits on the screen. Scrolling is necessary to see it all." />
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="Text View 2. Short text entry sits below Text View 1." />
</LinearLayout>
</ScrollView>
<LinearLayout
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="right">
<Button
android:id="@+id/button_1"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 1" />
<Button
android:id="@+id/button_2"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 2" />
<Button
android:id="@+id/button_3"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 3" />
<Button
android:id="@+id/button_4"
android:layout_height="fill_parent"
android:layout_width="wrap_content"
android:text="Button 4" />
</LinearLayout>
</LinearLayout>
새 질문을 게시 할 문제가 남아 있습니다.- 답변 # 1
- 답변 # 2
RelativeLayout에 사용 된 레이아웃을 변경하면 도움이됩니다. 화면 하단에 단추를 부착합니다.
또한 가변 길이 일 수있는 스크롤 가능 요소에서 layout_height = "0dip"및 layout_weight = "1"사용에 동의합니다.
수정
방금 코드를 이것으로 바꾸었고 HTC Desire에서 잘 작동했습니다. 테스트 케이스에서 잘 작동해야합니다. 선형 레이아웃을 사용하여 끝났지 만 괜찮아 보입니다.
<?xml version="1.0" encoding="utf-8"?> <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="fill_parent"> <ScrollView android:layout_width="fill_parent" android:layout_height="0dip" android:layout_weight="1" > <LinearLayout android:orientation="vertical" android:layout_width="fill_parent" android:layout_height="wrap_content"> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Text View 1. Text varies from a few lines to many more lines than what fits on the screen. Scrolling is necessary to see it all." /> <TextView android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Text View 2. Short text entry sits below Text View 1." /> </LinearLayout> </ScrollView> <LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="wrap_content"> <Button android:id="@+id/button_1" android:layout_height="fill_parent" android:layout_width="0dip" android:layout_weight="1" android:text="Button 1" /> <Button android:id="@+id/button_2" android:layout_height="fill_parent" android:layout_width="0dip" android:layout_weight="1" android:text="Button 2" /> <Button android:id="@+id/button_3" android:layout_height="fill_parent" android:layout_width="0dip" android:layout_weight="1" android:text="Button 3" /> <Button android:id="@+id/button_4" android:layout_height="fill_parent" android:layout_width="0dip" android:layout_weight="1" android:text="Button 4" /> </LinearLayout> </LinearLayout>
관련 자료
- html - 스크롤하는 동안 버튼을 맨 아래에 고정시키는 방법
- html - 하단 위의 위치 버튼
- javascript - 메뉴를 열 때 하단 div가 수정되었습니다
- Loading PHP code with ajax when scrolling to the bottom of page - 페이지 맨 아래로 스크롤 할 때 ajax로 php 코드로드 - iphone에서 작동하지 않습니다
- javascript - 위치 비활성화 - 페이지 하단에서 250px 일 때 스크롤 할 때 고정됨
- css - 화면 하단에 단추의 스타일을 지정하는 방법
- javascript - 가로로 스크롤하기위한 단추를 변경하여 세로로 스크롤하는 방법
- javascript - 스크롤 후 화면 하단에 div를 유지하는 방법
- javascript - 버튼을 사용하여 페이지 하단의 장바구니에 항목을 추가하려면 어떻게합니까?
- java - 스크롤 할 때 하단 탐색이 숨겨지는 것을 방지하는 방법
- html - 플렉스 박스 부트 스트랩 이미지 고정 하단
- javascript - 스크롤 할 때 원래 위치에 도달하면 고정 위치에서 맨 아래로 div의 초기 위치로 전환
- reactjs - 고정 된 메뉴 헤더 시맨틱 UI로 스티커 컨텐츠 스크롤
- html - 페이지 상단에서 양식을 시작하는 방법은 무엇입니까? '다음'버튼을 클릭 할 때마다 맨 아래로 계속 스크롤
- xaml - 3 개의 버튼을 바닥 중앙에 놓는 방법?
- java - 왜 javafx scrollpane이 즉시 맨 아래로 스크롤됩니까?
- html - 페이지 하단으로 스크롤하면 고정 탐색 모음에 액세스 할 수 없습니다
- Flutter에서 고정 열이있는 가로 스크롤 테이블을 만드는 방법은 무엇입니까?
- 버튼 위의 Inno Setup 베벨 라인에 텍스트를 추가하는 방법은 무엇입니까?
- 반응 네이티브에서 아래쪽 탐색 위에 구성 요소를 표시하는 방법은 무엇입니까?
- android - ConstraintLayout을 ScrollView 안에 넣을 수 있습니까?
- android : ToDoList 유형의 앱에 새 텍스트 필드가 표시되지 않음
- android - Flutter : 스크롤시 간단한 대화 상자를 전체 화면 대화 상자로 변환
- android - NavigationView의 메뉴가있는 사용자 지정 레이아웃?
- Svg는 장치에는 표시되지 않지만 Android XML에는 표시됩니다.
- android - 프로그래밍 방식으로 너비 레이아웃?
- Android 하단 시트 모달 (대화 상자)이 완전히 열리지 않음
- Android의 Glassmorphism 효과
- android - 수평 수직과 동일한 GridLayoutManager로 RecyclerView 수직 구분선을 설정하는 방법
- Android 스튜디오 미리보기가 실제 화면과 일치하지 않습니다.
ScrollView의 layout_height를 0dp로 설정하고 layout_weight를 1로 설정하십시오. 버튼을 화면 하단으로 밀어야하지만 더 이상은 없습니다.