androidcardview

How to Align an ImageView to the right side?


I want to set an imageview to the right side inside the cardview but aligning is not working... please suggest me

Layout

  <FrameLayout
    android:id="@+id/framelayout"
    android:layout_height="match_parent"
    android:layout_width="match_parent"/>
    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:id="@+id/lin1"
        android:orientation="vertical">
        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="horizontal">
        <android.support.v7.widget.CardView
            xmlns:android="http://schemas.android.com/apk/res/android"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:layout_marginLeft="05dp"
            android:layout_marginTop="15dp"
            android:id="@+id/casardviewvisit">
                <LinearLayout
                    android:layout_width="fill_parent"
                    android:layout_height="fill_parent"
                    android:background="#482048"
                    android:orientation="horizontal">
                <ImageView
                    android:layout_width="wrap_content"

                    android:layout_height="wrap_content"
                    android:src="@drawable/omg"/>
                <TextView
                    android:layout_width="wrap_content"
                    android:layout_height="wrap_content"
                    android:textSize="20dp"
                    android:textColor="#fff"
                    android:textStyle="bold"
                    android:layout_marginLeft="20dp"
                    android:layout_gravity="center"
                    android:text="Add Order"/>

                    <ImageButton
                        android:layout_width="wrap_content"
                        android:layout_height="wrap_content"
                        android:src="@drawable/sent"
                        android:layout_gravity="right"
                        android:id="@+id/imageButtsdon" />
                </LinearLayout>
        </android.support.v7.widget.CardView>
    </LinearLayout>
  </framelayout>

Like this way i am trying but it is not working and i don't know why this is not working


Solution

  • Make your TextView stretched by doing

    android:layout_width="0dp"
    android:layout_weight="1"