多个ListView和按钮widht

时间:2016-10-29 16:07:56

标签: android xml android-layout listview button

我试图为Android应用做this layout,但我不断得到不同的结果。我的第一个问题是我只能看到第一个ListView,而第二个总是被隐藏。第二个是我想要创建3个具有"标签样式"的按钮。我尝试使用

var audio = $("#shop_audio")[0];
var speaker = $("#shop_speaker");

function resetAudio() {
    audio.play();
    audio.onended = function() {
      this.onended = null;
      this.src = "/path/to/a/different/src";
      speaker.one("click", resetAudio);
    }
}

speaker.one("click", resetAudio);

按钮,但我仍然无法获得该结果。 这是我目前的布局:

android:layout_weight= "0.33"

<?xml version="1.0" encoding="utf-8"?>

这是列表元素的布局

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Start"
    android:id="@+id/button"
    android:layout_weight=".33"
    android:layout_alignTop="@+id/buttonP"
    android:layout_centerHorizontal="true" />

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Previous"
    android:id="@+id/buttonP"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:layout_weight= "0.33"/>

<Button
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:text="Next"
    android:id="@+id/buttonN"
    android:layout_above="@+id/custom_list"
    android:layout_alignRight="@+id/custom_list"
    android:layout_alignEnd="@+id/custom_list"
    android:layout_weight= "0.33"/>

<ListView
    android:layout_below="@+id/button"
    android:id="@+id/custom_list"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:dividerHeight="1dp"
    android:layout_weight="0.5"/>

<ListView
    android:layout_below="@+id/custom_list"
    android:id="@+id/custom_list_2"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:dividerHeight="1dp" />

1 个答案:

答案 0 :(得分:0)

您应该尝试使用此Percent支持库完成布局: https://developer.android.com/topic/libraries/support-library/features.html#percent

当您需要根据百分比宽度和高度创建布局时,这非常有用。 有关如何有效使用它的互联网上有很好的教程

相关问题