2016-08-31 22 views
0

XMLデザインでは、2つのボタンを追加しますが、いずれかのボタンは問題なく動作しますが、デバイスの2番目のボタンは表示されません。 (ボタンの2つはXMLのListViewにとどまります)。私は誰かが私がなぜこれが起こったのかを理解するのを助けることができ、私はそれを修正することができればうれしいだろう。ありがとう。デバイス上にAndroidボタンが表示されない

XML([設定]ボタンは、問題のボタンです) - 私はあなたが達成しようとしているものだと思い

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
android:layout_width="match_parent" 
android:layout_height="match_parent" > 

<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="gg.gg.MainActivity"> 


    <TextView 
     android:layout_width="fill_parent" 
     android:layout_height="wrap_content" 
     android:gravity="center_horizontal" 
     android:text="Tasks" 
     android:background="#e2e2e2" /> 

    <ListView 
     android:id="@+id/list_todo" 
     tools:listitem="@layout/item_todo" 
     android:layout_width="match_parent" 
     android:layout_height="wrap_content"/> 

    <Button 
     android:layout_width="60dp" 
     android:layout_height="60dp" 
     android:src="@drawable/settings" 
     android:background="@drawable/settings" 
     android:onClick="ButtonClick" 
     android:id="@+id/settings" 
     android:layout_above="@+id/add_task" 
     android:layout_alignParentEnd="true" /> 

    <Button 
    android:layout_width="60dp" 
    android:layout_height="60dp" 
    android:id="@+id/add_task" 
    android:src="@drawable/addtask" 
    android:background="@drawable/addtask" 
    android:layout_alignParentBottom="true" 
    android:layout_alignEnd="@+id/settings" /> 

</RelativeLayout> 

+0

コードの要素に必要な重みを付けるようにしてください。 –

+0

私はあなたのXMLをダミープロジェクトに貼り付けました。(あなたがdrawableで奇妙なことをしないと仮定すると)、それらはお互いの上に現れます。これを表示しているAndroidのバージョンは何ですか? –

+0

@ChrisWard API 22 – proli2

答えて

0

はfloationActionButtonです。これを試してみてください:次のように

<?xml version="1.0" encoding="utf-8"?> 
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" > 

    <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="gg.gg.MainActivity"> 


     <TextView 
      android:layout_width="fill_parent" 
      android:layout_height="wrap_content" 
      android:gravity="center_horizontal" 
      android:layout_alignParentTop="true" 
      android:id="@+id/textview" 
      android:text="Tasks" 
      android:background="#e2e2e2" /> 

     <ListView 
      android:id="@+id/list_todo" 
      android:layout_width="match_parent" 
      android:layout_height="match_parent" 
      android:layout_below="@+id/textview" 
      /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|end" 
      android:layout_margin="@dimen/fab_margin" 
      android:layout_alignParentBottom="true" 
      android:layout_alignParentRight="true" 
      android:src="@android:drawable/ic_dialog_email" /> 

     <android.support.design.widget.FloatingActionButton 
      android:id="@+id/fab1" 
      android:layout_width="wrap_content" 
      android:layout_height="wrap_content" 
      android:layout_gravity="bottom|end" 
      android:layout_margin="@dimen/fab_margin" 
      android:layout_above="@+id/fab" 
      android:layout_alignParentRight="true" 
      android:src="@android:drawable/ic_dialog_email" /> 
    </RelativeLayout> 
    </FrameLayout> 
+0

まだ同じ問題です。 – proli2

+0

私の編集を参照してください。 – Nidhi

1

enter image description hereあなたのレイアウトは次のようになります。

<?xml version="1.0" encoding="utf-8"?> 
     <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" 
        android:layout_width="match_parent" 
        android:layout_height="match_parent" > 

     <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="gg.gg.MainActivity"> 


      <TextView 
       android:layout_width="fill_parent" 
       android:layout_height="wrap_content" 
       android:gravity="center_horizontal" 
       android:layout_alignParentTop="true" 
       android:id="@+id/textview" 
       android:text="Tasks" 
       android:background="#e2e2e2" /> 

      <ListView 
       android:id="@+id/list_todo" 
       tools:listitem="@layout/item_todo" 
       android:layout_width="match_parent" 
       android:layout_height="match_parent" 
       android:layout_above="@+id/linearlayout" 
       android:layout_below="@+id/textview" 
       /> 

      <LinearLayout 
       android:id="@+id/linearlayout" 
       android:layout_width="match_parent" 
       android:layout_height="wrap_content" 
       android:layout_alignParentBottom="true" 
       android:orientation="vertical" 
       > 
      <Button 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:src="@drawable/settings" 
       android:background="@drawable/settings" 
       android:onClick="ButtonClick" 
       android:id="@+id/settings" 

       /> 

      <Button 
       android:layout_width="60dp" 
       android:layout_height="60dp" 
       android:id="@+id/add_task" 
       android:src="@drawable/addtask" 
       android:background="@drawable/addtask" 

       /> 
      </LinearLayout> 
     </RelativeLayout> 
+0

申し訳ありませんが、まだ問題は解決していません。 – proli2

+0

@ proli2うまくいきました。スクリーンショットも添付しました。 – Rajendra

0

使用このためにアクションボタンをフローティング。

+0

まだ何もありません:( – proli2

+0

レイアウトをお送りします。 –

+0

フローティングボタンまたはシンプルボタンが必要ですか? –

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

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

<include 
    android:id="@+id/toolbar" 
    layout="@layout/toolbar" /> 



<LinearLayout 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentRight="true" 
    android:layout_centerVertical="true" 
    android:orientation="vertical"> 

    <ImageView 
     android:id="@+id/parking" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="6dp" 
     android:src="@mipmap/parking_locs" /> 

    <ImageView 
     android:id="@+id/roads" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     android:layout_marginRight="6dp" 
     android:layout_marginTop="10dp" 
     android:src="@mipmap/before_park_car" /> 

</LinearLayout> 

<ImageView 
    android:id="@+id/compass" 
    android:layout_width="wrap_content" 
    android:layout_height="wrap_content" 
    android:layout_alignParentBottom="true" 
    android:layout_alignParentRight="true" 
    android:layout_margin="10dp" 
    android:src="@mipmap/button_my_location" /> 
</RelativeLayout> 
+0

ボタンを追加してください。 –

関連する問題