VansFannel
VansFannel

Reputation: 45941

How can I design a layout bigger than phone's screen?

I'm developing an Android application and I want to design, in eclipse, a layout bigger than screen height.

I have a layout for a fragment and this fragment will be inside a ScrollView on FragmentActivity.

This is my fragment's layout:

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/user_pro_main_view"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <TextView
        android:id="@+id/text_state"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:text="@string/layout_state"
        android:textAppearance="?android:attr/textAppearanceLarge" />

</LinearLayout>

Do I have to change android:layout_height="match_parent" to make it bigger on eclipse's designer?

What do I have to do if I want to see the layout bigger on eclipse designer?

Upvotes: 6

Views: 3549

Answers (4)

Dmytro Danylyk
Dmytro Danylyk

Reputation: 19796

Answer is pretty simple: you can't view layout which is biggern then screen on Eclipse Editor.

Possible workarounds:
1. Comment part of top views (visible) to see bottom (which are invisible), then uncomment when ready to launch.
2. Change Device Preview to bigger resolution (Nexus 10), this will give you some extra space.

Upvotes: 2

rahul
rahul

Reputation: 2661

just calculate device height and width and add int value to calculated height and width at runtime at layouts height and width.

public void deviceDisplay(){

  Display display = getWindowManager().getDefaultDisplay();
  int width = display.getWidth();
  int height = display.getHeight();


 }

Upvotes: 0

TronicZomB
TronicZomB

Reputation: 8747

You would set android:layout_height="wrap_content" and as you add child elements beyond the physical screen it will continue to stretch the layout.

As for viewing this on Eclipse, I'm not sure. I personally would just run it on a device to view it.

Upvotes: 0

Chor Wai Chun
Chor Wai Chun

Reputation: 3236

You can always explicitly set the exact dp value in layout_height, but of course most of the time I don't think you want a fixed value, so do it programatically.

LinearLayout yourLayout; // Get it by findViewById()
yourLayout.setLayoutParams(new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, your_calculated_height));

Upvotes: 1

Related Questions