简体   繁体   中英

Layout for Android Application on TV

I am designing an application for TV. When I load my application to TV screen, I see it still has the sizes of a smartphone. I have been playing with different dpi's but not working. Spent a day on this.

What are the steps to design the layout so that it will fit the TV screen?

This is my xml file:

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/RelativeLayout1"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:layout_weight="1"
    android:background="#FFFFFF"
    android:gravity="center" >

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_centerHorizontal="true"
        android:contentDescription="@string/logimgdesc"
        android:src="@drawable/logo" />

    <Button
        android:id="@+id/btnStart"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="36dp"
        android:text="@string/start" />

    <Button
        android:id="@+id/btnDownload"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentRight="true"
        android:layout_marginRight="36dp"
        android:text="@string/download" />

    <Button
        android:id="@+id/btnStop"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignBaseline="@+id/spyonme"
        android:layout_alignBottom="@+id/spyonme"
        android:layout_alignLeft="@+id/btnLoadFP"
        android:text="@string/stop" />


</RelativeLayout>

There are many different ways to implement support for multiple-screen sizes. I'd suggest you read the Supporting Multiple Screens guide on the Android developer site.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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