아래 레이아웃 (더 큰 레이아웃의 일부)에서는 버튼을 클릭 할 때까지 컨테이너 레이아웃의 가시성이 "사라짐"으로 설정됩니다. 버튼 클릭에서 container_ll이 보이지 않으면 visible로 설정되고 사용자 정의보기가 reminderViews_ll 컨테이너에 추가됩니다.LinearLayout은 너비 0 (명시 적 설정 또는 가중치 포함)
보기가 추가되고 container_ll보기가 버튼 클릭시 표시됩니다. 다음은 단추를 클릭 한 후 다양한보기의 너비와 높이입니다.
container_ll width 420, height 96.
lineDivider_view width 420, height 2 (as expected)
reminder_img width 36, height 36 (as expected, hdpi phone)
reminderViews_ll width 0, height 96 (argh)
<LinearLayout
android:id="@+id/container_ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:visibility="gone"
>
<View style="@style/lineDivider_view" />
<ImageView
android:id="@+id/reminder_img"
android:layout_width="24dp"
android:layout_height="24dp"
android:layout_gravity="center_horizontal"
/>
<!-- Stick the actual Reminder TVs + Del buttons in here dynamically -->
<LinearLayout
android:id="@+id/reminderViews_ll"
android:orientation="vertical"
android:gravity="center"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1.0"
/>
</LinearLayout>
나는 여기에서 어디로 가야할지를 놓치고 있습니다. 나는 무효화 된 레이아웃을 생각하여 뷰를 보이게 한 후에 다시 그리도록 강요하지만, 그것은 나를 위해 일한 적이 없으며, reminderViews_ll이 높이 96을 얻을 수 있다면 문제가 될 수 없다. LinearLayout의 치수를 계산한다.
나는이 질문을 내가 쓰는만큼 많이 읽었기를 바랍니다. 항상 그렇듯이 모든 포인터가 감사합니다.
너비가 0dp로 설정된 이유를 묻는 사람들은 다음 질문과 대답을 참조하여 내가 미쳐 있지 않다는 것을 표시하십시오. D --http : //stackoverflow.com/questions/3470420/is-it - 안드로이드 선형의 가로 질러 - 버튼을 균일하게 배포 할 수 있습니다. – ataulm
컨테이너가 확장되어 XML (reminderViews_ll 내부)에 버튼을 설정하면 버튼이 표시됩니까? 그렇다면 "동적"코드에 문제가있을 수 있습니다. – dmon