Does Android have any equivalents to the struts and springs of iPhones?

I continue to struggle to find some equivalent of iPhone-tables and springs in Android. And don't talk about gravity :-)

Say gravity well, but then explain how I can prevent screen representations from appearing in LinearLayout or RelativeLayout. Or show me another layout that allows you to fill the screen without knocking things out of sight.

In iPhone Interface Builder, I would simply set the springs appropriately so that each view takes up as much space as is available, but nothing more. This allows iPhone layouts to properly handle orientation changes.

In Android, the main approach that I read about is to create several layout folders, such as layout port and layout, and then replicate the XML layout files over them, but this seems to be very error prone, and yet the only way. which I can stop getting a great user view by pressing other buttons on the screen to set its layout_height exactly for a specific screen size and orientation. Given that the range of Android displays is striking in the market, it seems like it will be more and more pain.

Here is an example:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical" android:layout_width="fill_parent"
    android:layout_height="fill_parent">
    <TextView android:layout_width="fill_parent"
        android:layout_height="wrap_content" android:text="@string/hello" />
    <ImageView android:id="@+id/imageView1" android:src="@drawable/icon"
        android:layout_height="320dip" android:layout_width="fill_parent"></ImageView>
    <SeekBar android:layout_height="wrap_content" android:id="@+id/seekBar1"
        android:layout_width="fill_parent"></SeekBar>
</LinearLayout>

all these are just default widgets. I challenge you to find another way to set the height of the ImageView so that it fills as much of the screen as possible without knocking the search bar out of sight. Try setting Imageview android: layout_height to fill_parent to see what I mean.

Relative Layouts Table Layouts . , - , , ...

, ( ), - , , , XML- .

+5
2

android:layout_weight, android:layout_width android:layout_height 0dp ( android:orientation).

Android , ...

+1

( , ), SpringLayout: https://github.com/sulewicz/springlayout. , , , , ( ):

<?xml version="1.0" encoding="utf-8"?>
<org.coderoller.springlayout.SpringLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white" >

    <TextView
        android:id="@+id/A"
        android:layout_width="match_parent"
        android:layout_height="32dp"
        app:layout_alignParentTop="true"
        android:text="Test" />

    <ImageView
        android:id="@+id/imageView1"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        app:layout_below="@id/A"
        app:layout_above="@+id/seekBar1"
        android:src="@drawable/ic_launcher" />

    <SeekBar
        android:id="@id/seekBar1"
        android:layout_width="match_parent"
        android:layout_height="32dp"
        app:layout_alignParentBottom="true" />

</org.coderoller.springlayout.SpringLayout>

0

All Articles