"Android Apps for Absolute Beginners 3 판"설명서를 따르고 있으며 API 19 (4.4.2)에서 안드로이드 프로젝트 용 중첩 된 LinearLayout이 붙어 있습니다 : Parent LinearLayout은 가로이고안드로이드 중첩 선형 레이아웃
하지만 내가 얻을 것은 : 수직 및 최종 결과는 다음과 같이해야합니다 두 아이의 LinearLayout을 개최하기로 내가 몇 시간을 시도
책의 교차 체크 코드 및 설명이 있지만 올바르게 이해할 수는 없습니다.<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools" tools:context=".MainActivity"
android:layout_width="match_parent" android:layout_height="match_parent"
android:orientation="horizontal" android:background="@drawable/galaxyinfoscreen" >
<LinearLayout android:orientation="vertical" android:layout_margin="12dip"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#00000000">
<TextView android:text="@string/hello_world" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:layout_marginLeft="48dip" android:textStyle="bold" />
<TextView android:text="@string/galaxy_name" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/galaxy_solar" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/galaxy_habit" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/galaxy_colony" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/galaxy_pop" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/galaxy_fleet" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
<TextView android:text="@string/galaxy_ships" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content" />
</LinearLayout>
<LinearLayout android:orientation="vertical" android:layout_margin="33dip"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:background="#00000000" >
<TextView android:text="@string/name_data" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/name" />
<TextView android:text="@string/solar_data" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/solar" />
<TextView android:text="@string/habit_data" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/habit"/>
<TextView android:text="@string/colony_data" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/colony" />
<TextView android:text="@string/pop_data" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/pop" />
<TextView android:text="@string/fleet_data" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/fleet" />
<TextView android:text="@string/ships_data" android:textColor="#FFFFFF"
android:layout_width="wrap_content" android:layout_height="wrap_content"
android:id="@+id/ships"/>
</LinearLayout>
</LinearLayout>
이 파일에서 누락 될 수있는 무엇 : 여기 activity_main.xml의 내용입니까? 원하는 결과를 얻으려면 어떻게해야합니까?
첫째 :
android:singleLine="true"
의 모든 목록보기에이 태그를 추가, 그래서 이것은 모든 텍스트 뷰의 위치에 대칭을 유지 현재 코드
이러한 항목을 표시하려면 listview를 사용해야합니다. –
@SarthakMittal 감사합니다.하지만 사용하고자하는 것이 아니기 때문에 (RelativeLayout과 다른 접근 방식을 취할 것입니다) 복잡한 응용 프로그램의 시작일 뿐이므로 책 저자가 마음에 쓴 것은 나중에 있습니다. 메뉴, 슬라이더 등이 될 수 있습니다. 따라서이 부분을 너무 많이 엉망으로 만들면 책의 지침을 따르지 못할 것입니다. 저자가 책에 실린 코드 (이 단계에서 그의 작업 코드는 출판 된 버전과 분명히 다르다)와 다운로드 된 (최종) 코드는 전혀 다른 복잡하고 복잡한 버전으로 무언가를 버린 것 같습니다. –
좋아요, 그래서 중력을 1로 설정하면 (말하자면) 두 선형 레이아웃 모두에서 효과가 있습니다. –