【问题标题】:Android FullScreen theme reduces height of displayed ButtonAndroid FullScreen 主题降低了显示按钮的高度
【发布时间】:2014-12-11 14:26:03
【问题描述】:

我有一个带有两个按钮的登录活动,一个是我的,另一个来自 Facebook SDK。 我可以看到 id 为“auth”的按钮在宽度和高度上等于 facebook 按钮。 如果在我设置的清单中

android:theme="@android:style/Theme.NoTitleBar.Fullscreen"

要全屏显示活动,我有一个奇怪的结果:我的 Button 的高度减小了,所以我看到了一个混搭的矩形。

这是login.xml的代码:

<?xml version="1.0" encoding="utf-8"?>
<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:facebook="http://schemas.android.com/apk/res-auto"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/login_bg"
android:fillViewport="true" >


<LinearLayout
        android:id="@+id/container"
        android:orientation="vertical"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content" >


    <LinearLayout
        android:id="@+id/header"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:padding="10dip"
        android:gravity="center" >

        <!-- Logo Start -->

        <ImageView
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:src="@drawable/logo_claim" />
        <!-- Logo Ends -->
    </LinearLayout>


    <LinearLayout
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:padding="10dip"
        android:orientation="vertical">

    <Button
     android:id="@+id/auth"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_gravity="center"
    android:background="@drawable/loginbutton"
    android:textColor="#FFFFFF"
    android:textStyle="bold"
    android:textSize="16sp"
    android:text="Login" />  


    </LinearLayout>



    <LinearLayout 
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:orientation="vertical"
        android:layout_margin="10dp"

        android:padding="10dip" >

        <com.facebook.widget.LoginButton
            android:id="@+id/authButton"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            facebook:login_text="Login with Facebook" />

    <com.facebook.widget.LoginButton
    android:id="@+id/logoutButton"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:text="Logout"
    android:visibility="gone" />


    </LinearLayout>
    </LinearLayout>

    </ScrollView>

【问题讨论】:

    标签: android button styles height themes


    【解决方案1】:

    您可以通过 java 代码而不是 xml 使活动全屏:

    requestWindowFeature(Window.FEATURE_NO_TITLE);
    this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN,WindowManager.LayoutParams.FLAG_FUL  LSCREEN);
    setContentView(R.layout.activity_main);
    

    【讨论】:

    • layout_width 属性取决于父布局:但在您的情况下,可能是 facebook 按钮不符合 Theme.NoTitleBar.Fullscreen 样式,并且当您以编程方式使用全屏时,它不会应用这种不符合全屏样式的样式...
    猜你喜欢
    • 2011-09-17
    • 1970-01-01
    • 2020-11-19
    • 1970-01-01
    • 2015-07-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-02-23
    相关资源
    最近更新 更多