Showing posts with label placement. Show all posts
Showing posts with label placement. Show all posts

Saturday, December 15, 2012

Android - Place Tab at the bottom


Here's the simplest, most robust, and scalable solution to get tabs on the bottom of the screen.
  1. In your vertical LinearLayout, put the FrameLayout above the TabWidget
  2. Set layout_height to wrap_content on both FrameLayout and TabWidget
  3. Set FrameLayout's android:layout_weight="1"
  4. Set TabWidget's android:layout_weight="0" (0 is default, but for emphasis, readability, etc)
  5. Set TabWidget's android:layout_marginBottom="-4dp" (to remove the bottom divider)

Thursday, August 9, 2012

Android - Placing Image Above Text in Button


Place the following in your layout XML file, replacing [image] with your image:
1
2
3
4
5
6
<Button
     android:id="@+id/groups_button_bg"
     android:layout_height="wrap_content"
     android:layout_width="wrap_content"
     android:text="Groups"
     android:drawableTop="@drawable/[image]" />
Using android:drawableTop="@drawable/...", we’re able to place an image abovethe button text. The following options are available for placing the image in different positions relative to the button text:
1
2
3
4
android:drawableLeft
android:drawableRight
android:drawableBottom
android:drawableTop
In addition, android:drawablePadding can be used to specify the amount of padding between the image and button text.