2016-07-29 70 views
1

我的布局与居中图片视图屏幕高度取决于主题

<?xml version="1.0" encoding="utf-8"?> 
<android.support.percent.PercentRelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    xmlns:app="http://schemas.android.com/apk/res-auto" 
    android:background="@color/WHITE"> 

    <ImageView 
     android:id="@+id/powered_by" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:src="@drawable/powered_by" /> 

    <ImageView 
     android:id="@+id/splash_logo" 
     android:src="@drawable/logo" 
     app:layout_widthPercent="70%" 
     app:layout_heightPercent="70%" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_centerInParent="true" 
     android:adjustViewBounds="true" 
     android:visibility="invisible" /> 

</android.support.percent.PercentRelativeLayout> 

这里是主题设置为我的活动

<style name="SplashTheme" parent="android:Theme.Holo.Light"> 
    <item name="android:windowBackground">@drawable/splash</item> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:windowFullscreen">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 

当我改变父主题android:Theme.DeviceDefault.LightImageView的出现有点偏高,而不是在屏幕的中心。似乎我的设备的父视图现在不是从屏幕底部开始,而是从底部工具栏开始(我使用带屏幕按钮的Nexus 5X)。

我想为现代对话框外观使用设备默认主题,但我也需要在所有设备上精确地显示此图像视图。

怎么办?

回答

0

看起来好像android:Theme.DeviceDefault.Light没有设置android:windowFullScreen。因此,您需要与家长android:Theme.DeviceDefault.Light一起创建自己的主题并更改要更改的项目的值

<style name="TestTheme" parent="android:Theme.DeviceDefault.Light"> 
    <item name="android:windowNoTitle">true</item> 
    <item name="android:windowFullscreen">true</item> 
    <item name="android:windowContentOverlay">@null</item> 
</style> 
+0

不幸的是,它对我不起作用。我使用了相同的样式,图像视图不以此为中心。 –

+0

需要发布布局代码,然后查看问题是否存在 – ganlaw