I want to achieve rounded corners for the tab that I've constructed in my application. So far I was able to come up with this
I would like my rounded corners to look as so. (I've coded it in such a way that only the right and left corners appear but when the states change it looks like the above image)
Below is the code that I've written so far. How can I achieve proper rounded corners through code ?
SELECTED TAB.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners
android:topRightRadius="10dp"
android:bottomLeftRadius="10dp"/>
<gradient
android:startColor="#000"
android:endColor="#000"
android:gradientRadius="400"
android:angle="-270"/>
</shape>
UNSELECTED TAB.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:angle="90"
android:startColor="#880f0f10"
android:centerColor="#8858585a"
android:endColor="#88a9a9a9"/>
<corners
android:topLeftRadius="10dp"
android:bottomRightRadius="10dp"/>
</shape>
Thanks for your response !! :)
I think you should use 4 shapes:
for left button not selected
for left button selected
for right button not selected
for right button selected
And then write selector to use for button background, see example for the left button (for the right just the similar):
<selector
xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape android:shape="rectangle">
<corners
android:topLeftRadius="10dp"
android:bottomLeftRadius="10dp"/>
<gradient
android:startColor="#000"
android:endColor="#000"
android:gradientRadius="400"
android:angle="-270"/>
</shape>
</item>
<item>
<shape android:shape="rectangle">
<gradient
android:angle="90"
android:startColor="#880f0f10"
android:centerColor="#8858585a"
android:endColor="#88a9a9a9"/>
<corners
android:topLeftRadius="10dp"
android:bottomLeftRadius="10dp"/>
</shape>
</item></selector>
In java file, put this
tabs.getTabWidget().getChildAt(0).setBackgroundResource(R.drawable.roundedcorners);
roundedcorners.xml:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<corners android:bottomLeftRadius="0dp"
android:bottomRightRadius="0dp"
android:topLeftRadius="5dp"
android:topRightRadius="5dp" />
</shape>
Created alternate shapes to solve the problem
Note: These xml files are in addition to the two mentioned.
SELECTED TAB ALTERNATE.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<corners
android:topLeftRadius="10dp"
android:bottomRightRadius="10dp"/>
<gradient
android:startColor="#000"
android:endColor="#000"
android:gradientRadius="400"
android:angle="-270"/>
</shape>
UNSELECTED TAB ALTERNATE.XML
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
>
<gradient
android:angle="90"
android:startColor="#880f0f10"
android:centerColor="#8858585a"
android:endColor="#88a9a9a9"/>
<corners
android:topRightRadius="10dp"
android:bottomLeftRadius="10dp"/>
</shape>
Afterwards, add this in your tab selection listener.
#Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
int selectedTabPosition = tab.getPosition();
View firstTab = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(0);
View secondTab = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(1);
if (selectedTabPosition == 0)
{ // that means first tab
firstTab.setBackground(getDrawable(R.drawable.selected_tab));
secondTab.setBackground(getDrawable(R.drawable.unselected_tab));
} else if (selectedTabPosition == 1)
{ // that means it's a last tab
firstTab.setBackground(getDrawable(R.drawable.selected_tab_alternate));
secondTab.setBackground(getDrawable(R.drawable.unselected_tab_alternate));
}
}
For those who still looking for solution. This is what i done.Put tablayout inside MaterialCardView,
<com.google.android.material.card.MaterialCardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="12dp"
app:cardCornerRadius="12dp"`enter code here`
app:strokeColor="?attr/colorAccent"
app:strokeWidth="1dp">
<com.google.android.material.tabs.TabLayout
android:id="#+id/tab_layout"
android:layout_width="match_parent"
android:layout_height="27dp"
app:tabGravity="fill"
app:tabIndicatorColor="?attr/colorAccent"
app:tabIndicatorGravity="stretch"
app:tabMaxWidth="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="#android:color/white"
app:tabTextAppearance="#android:style/TextAppearance.Widget.TabWidget"
app:tabTextColor="?attr/colorPrimary">
</com.google.android.material.tabs.TabLayout>
</com.google.android.material.card.MaterialCardView>
tabselector_backgroud.xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#drawable/gradient_tab_selected"
android:state_selected="true" />
<item android:drawable="#drawable/gradient_tab_unselected"
android:state_selected="false" />
</selector>
gradient_tab_selected.xml
<?xml version="1.0" encoding="UTF-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<gradient
android:angle="90"
android:centerColor="#color/lime"
android:endColor="#color/lime"
android:startColor="#color/lime"
android:type="linear" />
</shape>
gradient_tab_unselected
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<gradient
android:angle="90"`enter code here`
android:centerColor="#color/white"
android:endColor="#color/white"
android:startColor="#color/white"
android:type="linear" />
</shape>
I think this can be done with one drawable for one view. For 2 tab need only 2 drawable. This will also worked for tabs with border color.
For Left Tab:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false">
<layer-list >
<item>
<shape android:shape="rectangle" >
<solid android:color="#android:color/holo_red_dark" />
<corners android:radius="10dp"/>
</shape>
</item>
<item android:right="-10dp">
<shape>
<solid android:color="#android:color/holo_red_dark" />
<stroke
android:width="2dp"
android:color="#android:color/black" />
<corners android:radius="10dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_selected="true">
<layer-list >
<item >
<shape android:shape="rectangle" >
<solid android:color="#android:color/holo_green_dark" />
<corners android:radius="10dp"/>
</shape>
</item>
<item android:right="-10dp">
<shape>
<solid android:color="#android:color/holo_green_dark" />
<stroke
android:width="2dp"
android:color="#android:color/black" />
<corners android:radius="10dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
Left Tab Background Preview:
For Right Tab:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false">
<layer-list >
<item>
<shape android:shape="rectangle" >
<solid android:color="#android:color/holo_red_dark" />
<corners android:radius="10dp"/>
</shape>
</item>
<item android:left="-10dp">
<shape>
<solid android:color="#android:color/holo_red_dark" />
<stroke
android:width="2dp"
android:color="#android:color/black" />
<corners android:radius="10dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_selected="true">
<layer-list >
<item >
<shape android:shape="rectangle" >
<solid android:color="#android:color/holo_green_dark" />
<corners android:radius="10dp"/>
</shape>
</item>
<item android:left="-10dp">
<shape>
<solid android:color="#android:color/holo_green_dark" />
<stroke
android:width="2dp"
android:color="#android:color/black" />
<corners android:radius="10dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
Right Tab Background Preview:
If there is more than 2 tabs Then this if for Middle Tab:
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="false">
<layer-list >
<item>
<shape android:shape="rectangle" >
<solid android:color="#android:color/holo_red_dark" />
<corners android:radius="10dp"/>
</shape>
</item>
<item android:left="-10dp" android:right="-10dp">
<shape>
<solid android:color="#android:color/holo_red_dark" />
<stroke
android:width="2dp"
android:color="#android:color/black" />
<corners android:radius="10dp"/>
</shape>
</item>
</layer-list>
</item>
<item android:state_selected="true">
<layer-list >
<item >
<shape android:shape="rectangle" >
<solid android:color="#android:color/holo_green_dark" />
<corners android:radius="10dp"/>
</shape>
</item>
<item android:left="-10dp" android:right="-10dp">
<shape>
<solid android:color="#android:color/holo_green_dark" />
<stroke
android:width="2dp"
android:color="#android:color/black" />
<corners android:radius="10dp"/>
</shape>
</item>
</layer-list>
</item>
</selector>
Middle Tab Background Preview:
Drawables have both selected and unselected state
Another, completely different approach, might be to use a library like Appcelerator Titanium or PhoneGap.
Both libraries let you "program" your android in HTML5/CSS/Javascript. Where "rounded tabs" abound.
Just a thought ...
This code are for 2 tabs in tablayout:
One is selected and two is unselected mode
Drawable xml:
When selecting Left tab:
tabselectionleft:
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp"/>
<solid android:color="#android:color/white"/>
</shape>
notabselectionleft:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<gradient android:startColor="#color/colorAccent1" android:endColor="#color/colorAccent3"/>
<corners android:topRightRadius="5dp"
android:bottomRightRadius="5dp" />
</shape>
</item>
</layer-list>
When selecting right tab:
tabselectionright:
<?xml version="1.0" encoding="utf-8"?>
<shape android:shape="rectangle"
xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:bottomRightRadius="5dp"
android:topRightRadius="5dp"/>
<solid android:color="#android:color/white"/>
</shape>
notabselectionright:
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle"
android:useLevel="true">
<corners
android:bottomLeftRadius="5dp"
android:topLeftRadius="5dp" />
<gradient
android:endColor="#color/colorAccent3"
android:startColor="#color/colorAccent1" />
</shape>
</item>
In main layout tablayout decelartion
<android.support.design.widget.TabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="60dp"
app:tabMode="fixed"
app:tabGravity="fill"
android:fitsSystemWindows="true"
android:clickable="true"
app:tabIndicatorColor="#color/colorAccent2"
app:tabIndicatorHeight="3dp"
android:layout_marginTop="20dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
app:tabPaddingStart="10dp"
app:tabPaddingEnd="10dp"
android:clipToPadding="true"
android:clipChildren="true"
/>
Calling this drawable should happen programmatically as shown below:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_simple_tabs);
viewPager = (ViewPager) findViewById(R.id.viewpager);
setupViewPager(viewPager);
tabLayout = (TabLayout) findViewById(R.id.tabs);
tabLayout.setupWithViewPager(viewPager);
firstTab = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(0);
secondTab = ((ViewGroup) tabLayout.getChildAt(0)).getChildAt(1);
tabLayout.setOnTabSelectedListener(this);
firstTab.setBackground(getDrawable(R.drawable.tabselectionleft));
secondTab.setBackground(getDrawable(R.drawable.notabselectionleft));
}
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
int selectedTabPosition = tab.getPosition();
if (selectedTabPosition == 0)
{ // that means first tab
firstTab.setBackground(getDrawable(R.drawable.tabselectionleft));
secondTab.setBackground(getDrawable(R.drawable.notabselectionleft));
} else if (selectedTabPosition == 1)
{ // that means it's a last tab
firstTab.setBackground(getDrawable(R.drawable.notabselectionright));
secondTab.setBackground(getDrawable(R.drawable.tabselectionright));
}
Related
I was implementing a drawable file to add a background to my tabs but i want it to have corners . I've used a shape and corners tags all embedded into a selector tag but it has no effects to my background corners . May I please get your help ? here's the code i've implemented :
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:drawable="#color/bleue_sky" android:state_selected="true">
<shape android:shape="rectangle">
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp"
/>
</shape>
</item>
<item android:drawable="#color/blackTransparent"/>
</selector>
Try This
<com.google.android.material.tabs.TabLayout
android:id="#+id/tabLayout"
android:layout_width="match_parent"
android:layout_height="?actionBarSize"
android:background="#drawable/main_tab_bg"
android:paddingHorizontal="10dp"
android:visibility="visible"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:tabBackground="#drawable/tab_layout_background"
app:tabIndicator="#drawable/tab_layout_indicator"
app:tabIndicatorColor="#null"
app:tabIndicatorFullWidth="true"
app:tabIndicatorGravity="center"
app:tabMode="auto"
app:tabRippleColor="#null"
app:tabSelectedTextColor="#FFFFFF"
app:tabTextColor="#000000" />
res/drawable/main_tab_bg.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item>
<shape android:shape="rectangle">
<solid android:color="#DDDDDD"/>
</shape>
</item>
<item android:top="1dp" android:bottom="1dp">
<shape android:shape="rectangle">
<solid android:color="#FFFFFF"/>
</shape>
</item>
</layer-list>
res/drawable/tab_layout_background.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="9dp"
android:bottom="9dp">
<shape android:shape="rectangle">
<solid android:color="#color/transparent" />
<corners android:radius="15dp" />
<size android:height="30dp"/>
</shape>
</item>
</layer-list>
res/drawable/tab_layout_indicator.xml
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:top="9dp"
android:bottom="9dp">
<shape android:shape="rectangle">
<corners android:radius="15dp" />
<solid android:color="#000000" />
<size android:height="30dp"/>
</shape>
</item>
</layer-list>
output like this
New to programming, 3 weeks beginner.
I am making a button with stacked rectangles through drawable xml.
This is my button .xml code, very straight forward:
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#D5A04F"
tools:context=".MainActivity">
<android.support.design.widget.NavigationView
<Button
android:id="#+id/leftnavbar"
android:layout_width="212dp"
android:layout_height="279dp"
android:layout_marginTop="16sp"
android:layout_marginBottom="500sp"
android:background="#drawable/rounded_rectangle"
/>
</android.support.design.widget.NavigationView>
</android.support.constraint.ConstraintLayout>
and this is my drawable .xml
<layer-list xmlns:android="http://schemas.android.com/apk/res/android"
android:paddingBottom="#dimen/mr_dialog_fixed_width_minor"
android:paddingTop="#dimen/mr_dialog_fixed_width_major"
>
<item
android:top="5sp"
android:left="5sp"
android:right="5sp"
android:bottom="50sp">
<shape android:shape="rectangle">
<solid android:color="#D3AE71" />
<corners android:radius="20sp"/>
</shape>
</item>
<item
android:top="30sp"
android:left="30sp"
android:right="30sp"
android:bottom="600sp">s
<shape android:shape="rectangle">
<solid android:color="#E6E5E5" />
<corners android:radius="20sp"/>
</shape>
</item>
<item
android:top="160sp"
android:left="30sp"
android:right="30sp"
android:bottom="470sp">
<shape android:shape="rectangle">
<solid android:color="#E6E5E5" />
<corners android:radius="20sp"/>
</shape>
</item>
<item
android:top="290sp"
android:left="30sp"
android:right="30sp"
android:bottom="340sp">
<shape android:shape="rectangle">
<solid android:color="#E6E5E5" />
<corners android:radius="20sp"/>
</shape>
</item>
<item
android:top="420sp"
android:left="30sp"
android:right="30sp"
android:bottom="210sp"
>
<shape android:shape="rectangle">
<solid android:color="#E6E5E5" />
<corners android:radius="20sp"/>
</shape>
</item>
<item
android:top="550sp"
android:left="30sp"
android:right="30sp"
android:bottom="80sp">
<shape android:shape="rectangle">
<solid android:color="#E6E5E5" />
<corners android:radius="20sp"/>
</shape>
</item>
</layer-list>
The only item that is shown in drawable is the first, the rest of the rectangles fail to show.
Suggestions or pointers to the reason will be much apreciated. thank you for your time and attention...
First of all please do not use "sp" for things other than text font size.
Second, pls look into excessive size of your android:bottom, like 600sp for example - they are leaving no space for respective shapes.
Your button's height is too short,chang android:layout_height="279dp" to android:layout_height="700dp"
This is my TabLayout xml code:
<android.support.design.widget.TabLayout
app:tabBackground="#drawable/profile_tab_selector"
android:id="#+id/profileTabLayout"
android:layout_width="match_parent"
android:layout_height="28dp"
android:layout_marginEnd="16dp"
android:layout_marginStart="16dp"
app:tabGravity="fill"
app:tabIndicatorHeight="0dp"
app:tabMode="fixed"
app:tabSelectedTextColor="#color/colorPrimary"
app:tabTextColor="#color/white">
</android.support.design.widget.TabLayout>
And this one is for tabBackground="#drawable/profile_tab_selector":
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_selected="true">
<shape>
<stroke android:width="1dp" android:color="#color/white"/>
<solid android:color="#color/white"/>
</shape>
</item>
<item>
<shape>
<stroke android:width="1dp" android:color="#color/white"/>
<solid android:color="#color/blue"/>
</shape>
</item>
</selector>
I want to design it like this, with rounded cornenrs:
The problem is that in selector I can not detect the first and the last tabs to modify them. And this is the result:
You have given the shape in the drawable file , but you didn't give corner radius.
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"android:shape="rectangle">
<corners
android:bottomLeftRadius="15dp"
android:bottomRightRadius="15dp"
android:topLeftRadius="15dp"
android:topRightRadius="15dp" />
<stroke
android:width="10dp"
android:color="#android:color/transparent"></stroke>
<solid android:color="#23cf5a" />
</shape>
And you can design something like this too
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >
<corners
android:bottomLeftRadius="16dp"
android:bottomRightRadius="16dp"
android:radius="32dp"
android:topLeftRadius="16dp"
android:topRightRadius="16dp" />
<solid android:color="#color/tab_color" />
<padding
android:bottom="0dp"
android:left="0dp"
android:right="0dp"
android:top="0dp" />
<size
android:height="32dp" />
</shape>
Your Solution is here
Don't Use : app:tabBackground="#drawable/profile_tab_selector"
Use : android:background="#drawable/profile_tab_selector"
You also try it.
I want to make this shape,for that i tried layer-list to design such shape but it doesn't happen exactly what i want.
<?xml version="1.0" encoding="utf-8"?>
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape android:shape="rectangle">
<solid android:color="#color/APP_PRIMARY"/>
<corners android:topRightRadius="100dp"
android:bottomRightRadius="100dp"/>
</shape>
</item>
<item android:width="100dp" >
<shape android:shape="rectangle">
<solid android:color="#color/white"/>
<corners android:topRightRadius="90dp"
android:bottomRightRadius="90dp"/>
</shape>
</item>
</layer-list>
Output of above code is
Desired Output.
This is what you exactly want
<?xml version="1.0" encoding="utf-8"?><layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item >
<shape android:shape="rectangle">
<solid android:color="#color/colorPrimary"/>
<corners android:radius="90dp"
/>
</shape>
</item>
<item android:width="100dp" >
<shape android:shape="rectangle">
<solid android:color="#ffff"/>
<corners android:radius="90dp"/>
</shape>
</item>
<item android:width="90dp" >
<shape android:shape="rectangle">
<solid android:color="#color/red"/>
<corners android:radius="90dp"
/>
</shape>
</item>
Inform me either it works or not. Thanks
you can use horizontal linear layout consists of two views
the right view you can use this drawable
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The bottom layer is blue square.-->
<item
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp">
<shape>
<solid android:color="#color/accentYellowCanary" />
<size android:height="100dp"
android:width="200dp" />
<corners android:topLeftRadius="50dp"
android:bottomLeftRadius="50dp"
android:topRightRadius="50dp"
android:bottomRightRadius="50dp"/>
</shape>
</item>
<!-- The middle layer is green circle.-->
<item
android:left="5dp"
android:top="5dp"
android:right="150dp"
android:bottom="5dp">
<shape android:shape="oval">
<size
android:width="100dp"
android:height="100dp" />
<solid android:color="#FFF" />
</shape>
</item>
which will result :
and for the left one you can use
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<!-- The bottom layer is blue square.-->
<item
android:left="5dp"
android:top="5dp"
android:right="5dp"
android:bottom="5dp">
<shape>
<solid android:color= "#color/offWhite"/>
<size android:height="100dp"
android:width="200dp" />
<corners android:topLeftRadius="50dp"
android:bottomLeftRadius="50dp"
android:topRightRadius="50dp"
android:bottomRightRadius="50dp"/>
</shape>
</item>
I want to have a pattern as a background in my RelativeLayout which is repeated.
<RelativeLayout
android:layout_width="0dp"
android:layout_height="600dp"
android:layout_weight=".20"
android:background="#drawable/timetable_background"
android:tileMode="repeat" >
But the tileMode does not work and shows only one run.
This is my pattern:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="50dp" android:height="50dp">
<shape android:shape="rectangle" >
<solid android:color="#color/timetableEntryBackground1" />
</shape>
</item>
<item android:top="50dp" android:height="50dp">
<shape android:shape="rectangle" >
<solid android:color="#color/timetableEntryBackground2" />
</shape>
</item>
</layer-list>
What do I need to change, that the background repeats?
You should use the tileMode inside the item of your layer-list, like this:
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
<item android:bottom="50dp" android:height="50dp">
<shape android:shape="rectangle" >
<solid
android:color="#color/timetableEntryBackground1"
android:tileMode="repeat" />
</shape>
</item>
...
</layer-list>