简体   繁体   中英

How to hide my application window in android?

How to hide my application window through programmatically?

Is it possible?

setContentView( R.layout.screen1 );

This coding to start application window. How to hide this window. Is it possible?

Thanks.

Try with this,

MainActivity.java

        public class MainActivity extends Activity {
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        // Put you code to hide the layout
        RelativeLayout mLayout = (RelativeLayout) findViewById(R.id.mainLayout);
        mLayout.setVisibility(View.GONE);
    }
}

activity_main.xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/mainLayout"
    android:layout_width="match_parent"
    android:layout_height="match_parent" >

    <Button
        android:id="@+id/button1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="96dp"
        android:text="Button" />

</RelativeLayout>

Yeah its possible. Provide an id to the parent window of screen1 layout like:

android:id="@+id/main_layout"

and when you want to hide it, write something like:

final LinearLayout mainLayout = (LinearLayout)findViewById(R.layout.main_layout); // assuming its a LinearLayout

mainLayout.setVisibility(View.GONE);

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM