I want to make an activity which is mainly transparent except for a gridview and a textview, so my style is:
<style name="Theme.Transparent" parent="android:Theme">
<item name="android:windowIsTranslucent">true</item>
<item name="android:windowBackground">@android:color/transparent</item>
<item name="android:windowContentOverlay">@null</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowIsFloating">true</item>
<item name="android:backgroundDimEnabled">false</item>
</style>
and my layout:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView ... android:layout_gravity="bottom" />
<GridView ...
android:layout_gravity="bottom"
/>
However textview and gridview are in the exact center, ignoring my bottom layout gravity…
A
LinearLayoutcan not do this, use aRelativeLayoutinstead. ARelativeLayoutwill give you access to thecenterInParentattribute in it’s children..here:
You might be able to get rid of that
LinearLayout, and I would suggest messing around with this. It depends on how you need the view to look.Either way, a
RelativeLayoutand alayout_centerInParentshould do what you want.