android-relativelayout
Is there a way to fill parent minus a fixed number in Android RelativeLayout?
Put a android:layout_margin=”10dp” on the ImageButton, along with the android:layout_width=”fill_parent” android:layout_height=”fill_parent”
Expand TextView with wrap_content until the neighbor view reaches the end of the parent
You can archive this layout by TableLayout and shrinkColumns attribute. <?xml version=”1.0″ encoding=”utf-8″?> <LinearLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:orientation=”vertical” android:layout_width=”match_parent” android:layout_height=”match_parent”> <!– Row 1 –> <TableLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:shrinkColumns=”0″> <TableRow android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:gravity=”center_vertical”> <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:padding=”4dp” android:maxLines=”1″ android:ellipsize=”end” android:text=”abcdefghijklmnopqrstuvwxyz”/> <TextView android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:padding=”4dp” android:maxLines=”1″ android:ellipsize=”none” android:text=”rightText”/> </TableRow> </TableLayout> <!– Row 2 –> <TableLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” android:shrinkColumns=”0″> <TableRow … Read more
Scale background image to wrap content of layout
I had the same problem (I think), and the only solution I could find was this: <RelativeLayout android:layout_width=”match_parent” android:layout_height=”wrap_content” > <View android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:background=”@drawable/some_image” android:layout_alignTop=”@+id/actual_content” android:layout_alignBottom=”@id/actual_content” android:layout_alignLeft=”@id/actual_content” android:layout_alignRight=”@id/actual_content” /> <LinearLayout android:id=”@id/actual_content” android:layout_width=”match_parent” android:layout_height=”wrap_content” android:layout_alignParentTop=”true” > <!– more stuff … –> </LinearLayout> </RelativeLayout>
Circular dependencies cannot exist in RelativeLayout, android?
The problem is caused because there is a circular reference in the layout parameters. For example, when view B is layout_below view A, view A can’t reference view B anymore in it’s below, alignRight etc. This can also exist between multiple views: A references B references C. In that scenario C can’t reference A because … Read more
Android Relative Layout Align Center
This will work: <?xml version=”1.0″ encoding=”utf-8″?> <RelativeLayout xmlns:android=”http://schemas.android.com/apk/res/android” android:layout_width=”fill_parent” android:layout_height=”wrap_content” android:paddingRight=”15dp” > <ImageView android:id=”@+id/place_category_icon” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerVertical=”true” android:contentDescription=”ss” android:paddingTop=”10dp” android:src=”@drawable/ic_launcher” /> <TextView android:id=”@+id/place_distance” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_alignParentRight=”true” android:layout_centerVertical=”true” android:text=”320″ /> <TextView android:id=”@+id/place_title” android:layout_width=”wrap_content” android:layout_height=”wrap_content” android:layout_centerVertical=”true” android:layout_marginLeft=”15dp” android:layout_toRightOf=”@+id/place_category_icon” android:text=”Place Name” android:textColor=”#FFFF00″ android:textSize=”14sp” android:textStyle=”bold” /> </RelativeLayout>