SMK
SMK

Reputation: 324

How to overlay a small view on a Main view without fully covering main view?

So I need the view of my settings to display over my main page.where there is a "setting"button in Main page which opens this settings view. But I want My main page to be visible beneath my settings view which only covers a half or less of the main view.

I tried adding

<org.example.myCustomView 
    xmlns:android="http://schemas.android.com/apk/res/android"  
    android:layout_width="fill_parent"  
    android:layout_height="fill_parent"  
    android:theme="@android:style/Theme.Dialog" />

Which I found from stackoverflaw itself. But I cannot do it instead the application corrupts at button click.

I am not sure I got this too correct, Or is there any other clear way to do it? I replaced myCustomView with my relevent class and created the manifest also but it did not work.

If there is any other alternative way to do this mention to me.

I am not talking about how to place a TextView, Button, EditText on a view

I am talking about completely two layouts.

Below image is only an example to express my question.

enter image description here

Upvotes: 2

Views: 722

Answers (3)

Mansi Salvi
Mansi Salvi

Reputation: 363

Use FrameLayout.FrameLayout is like container.In it place first your bluelayout and then your settings layout.It will show as if settings layout is placed on top of your blue layout. and then hide and show your settings layout on the onclick when required. eg:

Upvotes: 1

Amrmsmb
Amrmsmb

Reputation: 1

I think you need to utilize layoutinflater. Here is a simple example how to use it

     setContentView(R.layout.yourMainView);
     LayoutInflater mInflater = LayoutInflater.from(getApplicationContext());
     View overView = mInflater.inflate(R.layout.yourSmallView, null);
     addContentView(overView, new LayoutParams(LayoutParams.MATCH_PARENT, 
            LayoutParams.MATCH_PARENT));

Upvotes: 1

zIronManBox
zIronManBox

Reputation: 5067

You could use a Dialog Fragment which would be much more simpler and show more complicated stuff on UI with better responsiveness. Have a look at Dialog fragment: http://developer.android.com/reference/android/app/DialogFragment.html

Upvotes: 0

Related Questions