简体   繁体   English

Android 布局似乎在设备和模拟器中被裁剪

[英]Android Layout seemed to be cropped on device and in emulator

The Graphical Layout(set to 10.1 1280x800) in Eclipse looks the way I want it to. Eclipse 中的图形布局(设置为 10.1 1280x800)看起来像我想要的那样。

But the device(Galaxy Tab 10.1 1280x800) seems to be cropped.但是设备(Galaxy Tab 10.1 1280x800)似乎被裁剪了。 I even tried it on a co-workers Asus Transformer(I believe same size as the Galaxy just higher density) and had the same look我什至在同事的 Asus Transformer 上试过(我相信与 Galaxy 的尺寸相同,只是密度更高)并且外观相同

I have spent the better part of 2 days trying to figure out what I am doing wrong.我花了 2 天的大部分时间试图找出我做错了什么。 I can't seem to find someone having a similar problem.我似乎无法找到有类似问题的人。 I am downloading the images from a server and displaying from the sdcard.我正在从服务器下载图像并从 SD 卡显示。 I read that most people are having problems with the images scaling.我读到大多数人都在图像缩放方面遇到问题。 I could see that being my problem, if it was just the background image was not scaling to fullscreen.我可以看到这是我的问题,如果只是背景图像没有缩放到全屏。 My entire layout isn't filling the screen.我的整个布局没有填满屏幕。

Graphical Layout http://www.nickmcgough.com/Eclipse%20screencap.jpg图形布局http://www.nickmcgough.com/Eclipse%20screencap.jpg

Galaxy Tab http://www.nickmcgough.com/Galaxy%20Tab%20screencap.jpg Galaxy Tab http://www.nickmcgough.com/Galaxy%20Tab%20screencap.jpg

Here is my layout xml这是我的布局 xml

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/main_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:gravity="fill"
android:scaleType="fitXY"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
tools:context=".MainActivity" >

<ImageView
    android:id="@+id/background"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_alignParentLeft="true"
    android:layout_alignParentTop="true"
    android:contentDescription="@string/app_name"
    android:scaleType="fitXY" />

<ImageView
    android:id="@+id/logo"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/main_toolbar"
    android:contentDescription="@string/app_name"
    android:maxHeight="320dp"
    android:maxWidth="320dp" />

<ListView
    android:id="@+id/category_list"
    android:layout_width="320dp"
    android:layout_height="wrap_content"
    android:layout_alignParentLeft="true"
    android:layout_below="@+id/logo" >
</ListView>

<TextView
    android:id="@+id/tagline"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_below="@+id/main_toolbar"
    android:layout_toRightOf="@id/logo"
    android:ems="10"
    android:maxHeight="30dp"
    android:textAppearance="?android:attr/textAppearanceLarge"
    tools:ignore="SelectableText" >
</TextView>

<ListView
    android:id="@+id/file_list"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignTop="@id/tagline"
    android:layout_below="@+id/tagline"
    android:layout_marginLeft="50dp"
    android:layout_marginRight="20dp"
    android:layout_marginTop="50dp"
    android:layout_toRightOf="@+id/category_list" >
</ListView>

<LinearLayout
    android:id="@+id/main_toolbar"
    android:layout_width="match_parent"
    android:layout_height="50dp"
    android:layout_alignParentLeft="true"
    android:layout_alignTop="@id/background"
    android:background="@drawable/menu_bar"
    android:orientation="horizontal" >

    <Button
        android:id="@+id/edit_btn"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="10dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/button_up"
        android:height="30dp"
        android:text="@string/editBtn"
        android:width="79dp" />

    <Button
        android:id="@+id/menu_btn"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/button_up"
        android:height="30dp"
        android:src="@drawable/button_up"
        android:text="@string/menuBtn"
        android:width="79dp" />

    <Button
        android:id="@+id/contacts_btn"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/button_up"
        android:height="30dp"
        android:src="@drawable/button_up"
        android:text="@string/contactsBtn"
        android:width="79dp" />

    <Button
        android:id="@+id/accounts_btn"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="775dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/button_up"
        android:height="30dp"
        android:src="@drawable/button_up"
        android:text="@string/accountsBtn"
        android:width="79dp" />

    <Button
        android:id="@+id/clear_btn"
        style="?android:attr/borderlessButtonStyle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/button_up"
        android:height="30dp"
        android:src="@drawable/button_up"
        android:text="@string/clearBtn"
        android:width="79dp" />

    <Button
        android:id="@+id/email_btn"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_gravity="center_vertical"
        android:layout_marginLeft="5dp"
        android:layout_marginRight="5dp"
        android:background="@drawable/email_link_up"
        android:height="30dp"
        android:src="@drawable/email_link_up"
        android:width="40dp" 
        style="?android:attr/borderlessButtonStyle" />

</LinearLayout>

</RelativeLayout>

Here is my manifest xml这是我的清单 xml

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ceilink.ulodmedia"
android:versionCode="1"
android:versionName="1.0" >

<uses-sdk
    android:minSdkVersion="11"
    android:targetSdkVersion="17" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />

<supports-screens
    android:anyDensity="true"
    android:largeScreens="true"
    android:normalScreens="true"
    android:resizeable="true"
    android:smallScreens="true"
    android:xlargeScreens="true" />

<application android:label="@string/app_name" 
    android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" 
    android:icon="@drawable/icon_144_release">
    <activity
        android:name="com.ceilink.ulodmedia.MainActivity"
        android:label="@string/app_name" >
        <intent-filter>
            <action android:name="android.intent.action.MAIN" />
            <category android:name="android.intent.category.LAUNCHER" />
        </intent-filter>
    </activity>
    <activity android:name="MainActivity"></activity>
    <activity android:name="LoginActivity"></activity>
    <activity android:name="ImageActivity"></activity>
    <activity android:name="RegionsActivity"></activity>
    <activity android:name="TOSActivity"></activity>
    <activity android:name="VideoActivity"></activity>

</application>

</manifest>

Thanks for any help.谢谢你的帮助。

Creating different layouts for different screen devices might help.为不同的屏幕设备创建不同的布局可能会有所帮助。 Create different layouts for modi, hdpi, xhdpi etc. Have a look here https://developer.android.com/guide/practices/screens_support.html为 modi、hdpi、xhdpi 等创建不同的布局。看看这里https://developer.android.com/guide/practices/screens_support.html

Supporting multiple screens 支持多屏

hope this helps you...希望这对你有帮助...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM