Reputation: 1042
I need one big image to take all the widht and about 80% of the height and I need a bunch of small image ot top of that big one. Both need to start in the top left corner. The big image will not be visible cause the small ones will cover it of course. Here's how small image should look like, and that's OK:
Beneath them I need one big image. I tried with two linear layouts but it did not work. These 36 small images are placed in 6 horisontal linear layouts. Here's my xml:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib30"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/bIzlazCigle"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:background="@drawable/buttons_final"
android:text="Izlaz"
android:textSize="19sp"
android:padding="0dp"
android:textColor="#ffffff" />
<Button
android:id="@+id/bKonacnoCigle"
android:layout_width="180dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:background="@drawable/buttons_final"
android:text="Konačno rešenje!"
android:padding="0dp"
android:textSize="19sp"
android:textColor="#ffffff" />
</LinearLayout>
</LinearLayout>
Upvotes: 0
Views: 299
Reputation: 1042
OK, here's the solution, if anyone needs it:
<?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"
android:orientation="vertical"
android:background="@drawable/background" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent" >
<ImageView
android:id="@+id/ivSlika"
android:layout_width="fill_parent"
android:layout_height="398dp"
android:background="@drawable/tesla" />
</LinearLayout>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:orientation="vertical" >
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib11"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib12"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib13"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib14"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib15"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib16"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib17"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib18"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib19"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib20"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib21"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib22"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib23"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib24"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib25"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib26"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib27"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib28"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib29"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib30"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<ImageButton
android:id="@+id/ib31"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib32"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib33"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib34"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib35"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
<ImageButton
android:id="@+id/ib36"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:src="@android:drawable/btn_star" />
</LinearLayout>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal" >
<Button
android:id="@+id/bIzlazCigle"
android:layout_width="60dp"
android:layout_height="40dp"
android:layout_marginLeft="10dp"
android:background="@drawable/buttons_final"
android:padding="0dp"
android:text="Izlaz"
android:textColor="#ffffff"
android:textSize="19sp" />
<Button
android:id="@+id/bKonacnoCigle"
android:layout_width="180dp"
android:layout_height="40dp"
android:layout_marginLeft="15dp"
android:background="@drawable/buttons_final"
android:padding="0dp"
android:text="Konačno rešenje!"
android:textColor="#ffffff"
android:textSize="19sp" />
</LinearLayout>
</LinearLayout>
</FrameLayout>
Upvotes: 0
Reputation: 6263
Try using a RelativeLayout
.
<RelativeLayout>
<ImageView (or whatever, for background image) />
<LinearLayout> <-- this here is the XML you posted
<LinearLayout>
<ImageButton/>
...
...
</LinearLayout>
</RelativeLayout>
If the Background (as an ImageView
) and the LinearLayout
are at the same depth and both children of a RelativeLayout
, they will stack on top of eachother.
You could replace RelativeLayout
with FrameLayout
, but don't because that View
has more overhead for construction and you aren't drawing a Fragment
so you don't need it.
Upvotes: 1
Reputation: 11112
You should try to use Frame Layout -> http://developer.android.com/reference/android/widget/FrameLayout.html
the way create the view you want is to create a layout (for example linear layout) containing the big image then adding it to the frame layout then create another layout (for example linear layout) that contain all the small image then adding it again to the frame layout so the layout with small images will be placed in front of the layout with big images
I hope this can answer your question, but if you have another question about my answer feel free to ask in the comment :)
Upvotes: 0