Android divide activity into two parts -
currently i'm developing application android tablet. search method or approach divide screen 2 pieces , make subview visible. don't know found effect (ios or android app).
for illustration have 2 pictures attached:
after click on view x subview should appear below (the rest of screen moved down):
does know effect? greetings!
in android studio, can inflate fragment activity.
here's example:
in main2activity.java
public class main2activity extends appcompatactivity { @override protected void oncreate(bundle savedinstancestate) { super.oncreate(savedinstancestate); setcontentview(r.layout.activity_main2); final framelayout framelayout = (framelayout) findviewbyid(r.id.framelayout); button btn = (button) findviewbyid(r.id.button3); btn.setonclicklistener(new view.onclicklistener() { @override public void onclick(view view) { plusonefragment myf = new plusonefragment(); framelayout.setvisibility(view.visible); fragmenttransaction transaction = getsupportfragmentmanager().begintransaction(); transaction.add(r.id.framelayout, myf); transaction.commit(); } }); } }
in activity_main2.xml
<?xml version="1.0" encoding="utf-8"?> <android.support.constraint.constraintlayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" tools:context="com.testing.testinglibraryapps.main2activity"> <button android:id="@+id/button3" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" app:layout_constrainttop_totopof="parent" android:layout_margintop="8dp" android:layout_marginleft="8dp" app:layout_constraintleft_toleftof="parent" android:layout_marginstart="8dp" /> <button android:id="@+id/button4" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" app:layout_constrainttop_totopof="parent" android:layout_margintop="8dp" android:layout_marginright="8dp" app:layout_constraintright_torightof="parent" android:layout_marginend="8dp" /> <framelayout android:id="@+id/framelayout" android:layout_width="0dp" android:layout_height="200dp" android:layout_marginleft="8dp" android:layout_marginright="8dp" android:layout_margintop="0dp" android:visibility="gone" app:layout_constraintleft_toleftof="parent" app:layout_constraintright_torightof="parent" app:layout_constrainttop_tobottomof="@+id/button3"> </framelayout> <button android:id="@+id/button5" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" android:layout_marginleft="8dp" app:layout_constraintleft_toleftof="parent" android:layout_margintop="0dp" app:layout_constrainttop_tobottomof="@+id/framelayout" /> <button android:id="@+id/button6" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="button" android:layout_marginright="8dp" app:layout_constraintright_torightof="parent" android:layout_margintop="0dp" app:layout_constrainttop_tobottomof="@+id/framelayout" /> </android.support.constraint.constraintlayout>
take look, put trick of framelayout visibility put view under them going down.
and plusonefragment in example, u can change own fragment
Comments
Post a Comment