VIGNESH
VIGNESH

Reputation: 2033

UI Alignment - Could not resolve

I have tried many ways and i could not get this alignment issue resolved . And i am not sure that where i am going wrong .

My XML :

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:gravity="center"
    android:orientation="vertical"
    android:background="@color/popover">

        <TextView
            android:id="@+id/textView1"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textColor="#000000"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="2dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView2"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textColor="#000000"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView3"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Large Text"
            android:textColor="#000000"
            android:layout_marginTop="2dp"
            android:layout_marginBottom="5dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:textAppearance="?android:attr/textAppearanceLarge" />

        <TextView
            android:id="@+id/textView4"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Medium Text"
            android:textColor="#000000"
            android:paddingLeft="20dp"
            android:paddingRight="20dp"
            android:layout_margin="5dp"
            android:textAppearance="?android:attr/textAppearanceMedium" />

        <TextView
            android:id="@+id/textView5"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Small Text"
            android:textColor="#000000"
            android:layout_margin="5dp"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <TextView
            android:id="@+id/textView6"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:text="Small Text"
            android:textColor="#000000"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp"
            android:textAppearance="?android:attr/textAppearanceSmall" />

        <LinearLayout
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:orientation="horizontal"
            android:layout_marginTop="15dp"
            android:layout_marginBottom="10dp"
            android:layout_marginLeft="5dp"
            android:layout_marginRight="5dp" >

            <ImageButton
                android:id="@+id/locationalert_dont"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginLeft="5dp"
                android:layout_marginRight="5dp"
                android:background="@drawable/dontallow_btnaction" />

            <ImageButton
                android:id="@+id/locationalert_ok"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_marginRight="5dp"
                android:background="@drawable/ok_btnaction" />

        </LinearLayout>

    </LinearLayout>

And the class file :

public void showLocationDialog()
    {

        Dialog dialog = new Dialog(Homescreen.this);
        dialog.setContentView(R.layout.locationalert);

        TextView tv1 = (TextView)dialog.findViewById(R.id.textView1);

        TextView tv2 = (TextView)dialog.findViewById(R.id.textView2);

        TextView tv3 = (TextView)dialog.findViewById(R.id.textView3);

        TextView tv4 = (TextView)dialog.findViewById(R.id.textView4);

        TextView tv5 = (TextView)dialog.findViewById(R.id.textView5);

        TextView tv6 = (TextView)dialog.findViewById(R.id.textView6);

        ImageButton ok = (ImageButton)dialog.findViewById(R.id.locationalert_ok);

        ImageButton dont = (ImageButton)dialog.findViewById(R.id.locationalert_dont);

        dialog.show();

    }

Actually i have a button in a class and click on it pop-ups this dialog . But the dialog appears as

enter image description here

In the Screenshot , i am getting a header black bar along with the pop-up dialog and i am not sure how to remove it .

Any related answers are advisable . Thanks in advance .

Upvotes: 0

Views: 79

Answers (5)

Pihu
Pihu

Reputation: 1039

You can hide the title bar and the background of a dialog like this:

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); 
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

Hope this helps..:)

Upvotes: 0

Ali
Ali

Reputation: 1915

this is the solution of your problem

 Dialog dialog = new Dialog(Homescreen.this,android.R.style.Theme_Translucent_NoTitleBar );
        dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);
        dialog.setContentView(R.layout.locationalert);

Upvotes: 0

duggu
duggu

Reputation: 38439

try below code :-

final Dialog dialog = new Dialog(ActivityName.this);
dialog.requestWindowFeature(Window.FEATURE_NO_TITLE); // hide title bar
dialog.setContentView(R.layout.vip_services_other_dialog);

// hide black background
dialog.getWindow().setBackgroundDrawable(new ColorDrawable(android.graphics.Color.TRANSPARENT));

refer link

Upvotes: 1

qulfille
qulfille

Reputation: 208

In your XML(locationalert), set Linear Layout Background as:

android:background="@android:color/transparent"

and in your showLocationDialog() method, add

dialog.getWindow().setBackgroundDrawable(new ColorDrawable(R.color.YOURCOLOR));

Upvotes: 0

Pararth
Pararth

Reputation: 8134

Use

dialog.requestWindowFeature(Window.FEATURE_NO_TITLE);  

Please also go through:

Android Window and Related Flags and Dialogs

Upvotes: 1

Related Questions