skip to Main Content

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?

ebay App.
Many thanks.

3

Answers


  1. or you could use margins at the bottom, for the view which is just above the empty space.

    android:layout_marginBottom="1dp"
    
    Login or Signup to reply.
  2. 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.

    Login or Signup to reply.
  3. 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>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search