Мой основной макет main.xml просто содержит два LinearLayouts:
- В первом
LinearLayoutразмещаются aVideoViewиButton, - Второй
LinearLayoutразмещаетEditText, и этотLinearLayoutустановил значение видимости в значение GONE "(android:visibility="gone")
как показано ниже:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:orientation="vertical"
>
<LinearLayout
android:id="@+id/first_ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<VideoView
android:id="@+id/my_video"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="9"
/>
<Button
android:id="@+id/my_btn"
android:layout_width="30dip"
android:layout_height="30dip"
android:layout_gravity="right|bottom"
android:layout_weight="1"
/>
</LinearLayout>
<LinearLayout
android:id="@+id/second_ll"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:paddingTop="2dip"
android:visibility="gone"
>
<EditText
android:id="@+id/edit_text_field"
android:layout_height="40dip"
android:layout_width="fill_parent"
android:layout_weight="5"
android:layout_gravity="center_vertical"
/>
</LinearLayout>
</LinearLayout>
Я успешно реализовал функцию, которая при нажатии Button (с id my_btn) отображается 2 LinearLayout с полем EditText со следующим кодом Java:
LinearLayout secondLL = (LinearLayout) findViewById(R.id.second_ll);
Button myBtn = (Button) findViewById(R.id.my_btn);
myBtn.setOnClickListener(new OnClickListener(){
@Override
public void onClick(View v){
int visibility = secondLL.getVisibility();
if(visibility==View.GONE)
secondLL.setVisibility(View.VISIBLE);
}
});
С приведенным выше кодом Java 2 LinearLayout с EditText отображается как , добавив ниже 1st LinearLayout, который имеет смысл.
НО, мне нужно: при нажатии Button (id: my_btn) отображается 2nd LinearLayout с EditText поверх 1st LinearLayout, который выглядит так: 2nd LinearLayout с EditText поднимается снизу экрана, а 2nd LinearLayout с EditText только занимают часть экрана снизу, что первый LinearLayout все еще отображается, как показано на рисунке ниже:

Итак, когда нажата Button (id: my_btn), как показать 2nd LinearLayout с EditText поверх 1 LinearLayout вместо добавления 2nd LinearLayout ниже 1st LinearLayout программно?
