android - How to show one layout on top of the other programmatically in my case? -
android - How to show one layout on top of the other programmatically in my case? -
my main layout main.xml contains 2 linearlayouts:
the 1stlinearlayout hosts videoview , button, the 2nd linearlayout hosts edittext, , linearlayout has set visibility value "gone" (android:visibility="gone") like below:
<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> i implemented feature when button (with id my_btn) pressed, 2nd linearlayout edittext field shown, next java code:
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); } }); with above java code, 2nd linearlayout edittext shown appending below 1st linearlayout makes sense.
but, need is: when button(id: my_btn) pressed, 2nd linearlayout edittext is shown on top of 1st linearlayout, looks 2nd linearlayout edittext rising bottom of screen, , 2nd linearlayout edittext occupy part of screen bottom, that's 1st linearlayout still visible, image below showed:
so, when button(id: my_btn) pressed how show 2nd linearlayout edittext on top of 1st linearlayout instead of appending 2nd linearlayout below 1st linearlayout programmatically?
use framelayout 2 children. 2 children overlapped. recommended in 1 of tutorials android actually, it's not hack...
here illustration textview displayed on top of imageview:
<framelayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout_width="fill_parent" android:layout_height="fill_parent"> <imageview android:layout_width="fill_parent" android:layout_height="fill_parent" android:scaletype="center" android:src="@drawable/golden_gate" /> <textview android:layout_width="wrap_content" android:layout_height="wrap_content" android:layout_marginbottom="20dip" android:layout_gravity="center_horizontal|bottom" android:padding="12dip" android:background="#aa000000" android:textcolor="#ffffffff" android:text="golden gate" /> </framelayout> android android-layout android-emulator android-widget android-manifest
Comments
Post a Comment