I am working on piano app and I am facing some problems with the layout creation. I want to create a layout like below:
But I am able to create only this
Now I want to add all the black buttons but problem is that I am not able to add view above those buttons. How can I do this? My current layout code is below, please suggest me how can I achieve this. Now I am able to click all the buttons, once I add all the buttons then each button should be clickable.
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:orientation="horizontal" >
<LinearLayout
android:id="@+id/relativeLayout2"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@color/white"
android:weightSum="1.5" >
<ImageView
android:id="@+id/bw1"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw2"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw3"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw4"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw5"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw6"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw7"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw8"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw9"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw10"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw11"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw12"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw13"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw14"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
<ImageView
android:id="@+id/bw15"
android:layout_width="0dip"
android:layout_height="match_parent"
android:layout_weight=".1"
android:background="@drawable/blacknew" />
</LinearLayout>
</RelativeLayout>
you may get what you want by using layout containers, with this it is possible to overlay buttons and lables
I would suggest drawing these white and black keys on your own. Use the View class, override draw() method and go for it. Of course you can try to use RelativeLayout, but later you'll have more problems with that (like multiple touches and slides detection).