【问题标题】:Android scaling(Layout) problemsAndroid缩放(布局)问题
【发布时间】:2014-10-01 12:58:26
【问题描述】:

正如您从标题中所理解的那样,我目前正在构建的扩展存在一些问题。在我的 GalaxyS5 上,一切运行良好,但是当我尝试在屏幕更大的三星平板电脑上运行它时,我遇到了一些问题。

因为我不能发布图片,所以这里有一个链接,可以直观地描述我的问题: https://www.sendspace.com/file/83j0tp

更新:因为我有10个声望帖子,我可以添加图片。

三星 S5

状态 1

状态 2

SamsungTab(平板电脑)

状态 1

状态 2

这是我的 XML 代码:

我希望你们能帮助我。

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent">


<LinearLayout
    android:layout_alignParentBottom="true"
    android:orientation="horizontal"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:id="@+id/linearLayout5"
    android:layout_alignTop="@+id/linearLayout6">

    <ImageView
        android:id="@+id/loginImage"
        android:layout_width="fill_parent"
        android:layout_height="match_parent" />
    <ImageView
        android:id="@+id/loginImage2"
        android:layout_width="fill_parent"
        android:layout_height="match_parent" />

    <TextView
        android:layout_width="372dp"
        android:layout_height="match_parent"
        android:layout_alignLeft="@+id/loginImage"
        android:layout_alignTop="@+id/loginImage"
        android:layout_alignRight="@+id/loginImage"
        android:layout_alignBottom="@+id/loginImage"
        android:gravity="center|right"
        android:id="@+id/textLoginmail" />
</LinearLayout>

<LinearLayout
    android:layout_alignParentBottom="true"
    android:layout_width="fill_parent"
    android:layout_height="49.5dp"
    android:layout_marginTop="45dp"
    android:id="@+id/linearLayout6"
    android:weightSum="1"
    android:layout_alignParentEnd="false">

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:text="Registreer"
        android:gravity="center|right"
        android:textColor="#FFFFFF"
        android:id="@+id/textRegistreer"
        android:layout_weight="0.72" />

    <TextView
        android:layout_width="wrap_content"
        android:layout_height="fill_parent"
        android:id="@+id/textLogin"
        android:layout_weight="0.44"
        android:text="Login"
        android:textColor="#FFFFFF"
        android:gravity="center"/>

    <Button
        android:layout_width="81dp"
        android:layout_height="wrap_content"
        android:background="@android:color/transparent"
        android:id="@+id/closeButton" />

</LinearLayout>

<FrameLayout
    android:layout_above="@id/linearLayout5"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_marginBottom="25dp"
    android:id="@+id/framelayout_facebook">

    <ImageView
        android:id="@+id/facebookImage"
        android:layout_width="match_parent"
        android:layout_height="match_parent" />

    <com.facebook.widget.LoginButton
        android:id="@+id/fb_login_button"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:drawableLeft="@drawable/ic_action_labels"
        android:drawableRight="@drawable/ic_action_next_item"
        android:layout_marginLeft="20dp"
        android:layout_marginRight="20dp"/>
    <LinearLayout
        android:clickable="true"
        android:focusable="true"
        android:focusableInTouchMode="true"
        android:orientation="horizontal"
        android:id="@+id/overlay_for_terms"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:weightSum="1">

        <TextView
            android:layout_width="wrap_content"
            android:layout_height="match_parent"
            android:gravity="center"
            android:textColor="#FFFFFF"
            android:id="@+id/textFacebook"
            android:layout_weight="0.90" />
    </LinearLayout>
</FrameLayout>

【问题讨论】:

  • 关注三星s5,标签有不同的屏幕尺寸developer.android.com/training/multiscreen/screensizes.html
  • s5 从hdpi 文件夹中获取文件.. 检查您可能从xhdpixxhdpi 获取的标签文件夹
  • 图片是从服务器中挑选出来的。你检查过sendspace文件吗?我不认为这是 hdpi 或 mdpi 的问题,我认为我的代码不正确。
  • 不知道是否重要,但我注意到linearLayout6中定义的weightSum小于子视图的权重之和。尝试忽略 weightSum 或使其更大。
  • 你说的是真的uvo。其中一个按钮变得比另一个稍大,但这并不能解决我的问题,即在白色标记之间保持固定但变得大得像地狱的文本......你在图片上看不到它,但即使在按钮之外也是如此它们是可点击的。感谢您的反应

标签: android layout scale


【解决方案1】:

问题解决了。我认为告诉程序应该在哪个屏幕上使用哪个宽度会是一个更好的主意。

感谢 Gaetan 的提示,它就像一个魅力。 Using different layout style on different screens (Android)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-11-05
    • 2011-03-18
    • 2019-02-05
    • 1970-01-01
    相关资源
    最近更新 更多