Reputation: 1962
I'm developing an App, and I need to draw borders and separators on a View, like the eBay app.
I think on a combination of shapes and view with 1dp. There is another easy way?
Many thanks.
Upvotes: 3
Views: 1009
Reputation: 17352
Create a 9-patch image for the outside border. Use that as the background resource and it will give you the rounded corners with solid border. For dividers, you can create a simple view and have another background resource that's a simple image with the same color as the border in the 9-patch.
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical">
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@drawable/roundedborder"
android:orientation="vertical">
<!-- Put Saved Searches display code here. Probably LinearLayout/horizonal -->
<TextView
android:layout_width="fill_parent"
android:layout_height="1dp"
android:background="@drawable/simpleborder"
android:layout_margin="3dp"/> <!-- Spacer! -->
<!-- Put Favorite sellers display code here. Probably LinearLayout/horizonal -->
</LinearLayout>
</LinearLayout>
Upvotes: 1
Reputation: 4262
If you mean how the views are grouped together so that some have curved corners on top, others in the bottom plus padding or a margin, and others with no curved corners at all, then this is one way to do it.
If you are using ListView with ListAdapter then When overriding getView(int position, View convertView, ViewGroup parent)
determine from position
what view should be returned and return it. You can change the view's padding and margins before returning it.
Also, it'll be more efficient if you override getItemViewType(int position)
and return a constant representation a view type for a specific position so that Android can reuse views and you wont have to inflate a new one or change the attributes every time.
Upvotes: 0
Reputation: 29141
or you could use margins at the bottom, for the view which is just above the empty space.
android:layout_marginBottom="1dp"
Upvotes: 0