如何在片段list_content之前添加一个plusonebutton或任何其他元素

时间:2014-02-23 21:15:46

标签: android android-layout

如何在片段list_content之前添加plusonebutton或任何其他元素 这就是我尝试过的,但按钮已经超出了列表!

<fragment xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/sl"
    android:name="dev.dev.dev.SListFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    tools:context=".SActivity"
    tools:layout="@android:layout/list_content"  >

<com.google.android.gms.plus.PlusOneButton
  xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
  android:id="@+id/plus_one_button"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
  plus:size="standard"
  plus:annotation="inline" />

</fragment>

这是上面的快照 enter image description here

我需要列表上方的google + plus按钮,而不是像这样:

enter image description here

1 个答案:

答案 0 :(得分:0)

终于找到了解决方案:

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".SActivity" >

<com.google.android.gms.plus.PlusOneButton
  xmlns:plus="http://schemas.android.com/apk/lib/com.google.android.gms.plus"
  android:id="@+id/plus_one_button"
  android:layout_width="wrap_content"
  android:layout_height="wrap_content"
    android:layout_marginTop="16dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
  plus:size="standard"
  plus:annotation="inline" />

<fragment

    android:id="@+id/sl"
    android:name="dev.dev.dev.SListFragment"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:layout_marginTop="50dp"
    android:layout_marginLeft="16dp"
    android:layout_marginRight="16dp"
    tools:context=".SActivity"
    tools:layout="@android:layout/list_content"  />

</RelativeLayout>