0

I need a LinearLayout to have the same width as a dialog would have it. Additionally this LinearLayout is within another GroupView (match_parent)

So:

-LinearLayout(match_parent, match_parent)
+-LinearLayout(dialog_width, wrap_content)

Any ideas how to achive this?

Edit:

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:gravity="center">

    <!-- This is the one which should be in dialog width -->
    <LinearLayout
        android:paddingTop="16dp"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:gravity="center_horizontal"
        android:orientation="vertical">

        <TextView
            android:text="Hi there"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"/>

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:gravity="end">

            <Button
                android:id="@android:id/button1"
                style="?android:attr/borderlessButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@android:string/ok"/>

            <Button
                android:id="@android:id/button2"
                style="?android:attr/borderlessButtonStyle"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:text="@android:string/cancel"/>
        </LinearLayout>
    </LinearLayout>
</LinearLayout>

May be also important to say: It should also change size on tablet/rotation etc.

andre
  • 1,618
  • 2
  • 19
  • 38
  • Can you give more detail your layout code? – Liem Vo Mar 07 '16 at 21:53
  • Updated the Question itself – andre Mar 07 '16 at 22:12
  • Can you show your expectation screen? It will help me easy to see what is the different in your code. – Liem Vo Mar 08 '16 at 04:21
  • Open an AlertDialog. This is what I expect. I am using this layout in an activity. Why not using dialog itself? Cause I need a SharedElement-Transition. – andre Mar 08 '16 at 07:40
  • Smth like this: http://stackoverflow.com/questions/28507907/shared-element-transition-with-dialog-activity But this guy sets his width to 1/3rd of the screen. I could force the size to a fixed percentage of the screen, but then it looks shit for tablets. And if I use a dialog theme for the activity (which would make it look correct), the shared element is not shown above and below the dialog top/bottom borders, this is why I have a LinearLayout as root element – andre Mar 08 '16 at 08:02

0 Answers0