GridView控件之间的渐变线条 [英] Gradient Lines between GridView

查看:135
本文介绍了GridView控件之间的渐变线条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我要像下面的GridView之间的图像的一行:

I want a line like below image between gridview:

随着我都试过了。

GridView的XML:

GridView 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" >

<GridView
    android:id="@+id/gridhouseindex"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:listSelector="@null"
    android:smoothScrollbar="true"
    android:stretchMode="columnWidth"
    android:numColumns="2"
    android:verticalSpacing="22dp">
</GridView>

适配器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="horizontal" >

<LinearLayout
    android:layout_width="wrap_content"
    android:layout_height="match_parent"
    android:orientation="vertical" >

    <LinearLayout
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:orientation="horizontal" >

        <ImageView
            android:id="@+id/imgViewHouseIndex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical|center_horizontal|center"
            android:layout_marginLeft="20dp"
            android:adjustViewBounds="true"
            android:src="@drawable/univer" />

        <TextView
            android:id="@+id/txtViewHouseIndex"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_gravity="center_vertical"
            android:text="TextView"
            android:textSize="12sp"
            android:textStyle="bold" />
    </LinearLayout>

   <View
        android:layout_width="match_parent"
        android:layout_height="1dp"
        android:background="@drawable/grid_line" />
</LinearLayout>

   <View
        android:layout_width="1dp"
        android:layout_height="match_parent"
        android:background="@drawable/grid_line" />

网格线XML:

<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle" >

<stroke
    android:width="2dp"
    android:color="#b6a9a9" />

<gradient
    android:angle="90"
    android:endColor="#b6a9a9"
    android:startColor="#FFFFFF" />

<corners
    android:bottomLeftRadius="1dp"
    android:bottomRightRadius="1dp"
    android:topLeftRadius="1dp"
    android:topRightRadius="1dp" />

通过使用上述code,让我很喜欢下面的图片:

By using the above code, i am getting like following image:

能否有人告诉我,我要去的地方错了或什么,我必须做的,以获得精确的输出。

Can someone please tell me, where i am going wrong or what i have to do to get the exact output.

更新:搜索结果
这是我收到的输出。搜索结果

Updated:

This is the output i am getting.

推荐答案

有关横向行: gradientbackground.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:shape="rectangle" >
    <gradient
        android:angle="180"
        android:centerColor="#000000"
        android:endColor="#F6F6F6"
        android:startColor="#F6F6F6" />
</shape>

布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white"
    android:splitMotionEvents="false" >
    <View
        android:id="@+id/divider"
        android:layout_width="fill_parent"
        android:layout_height="1dp"
        android:layout_centerVertical="true"
        android:background="@drawable/backgrad" />
</RelativeLayout>

有关垂直行: gradientbackground.xml

<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
    android:dither="true"
    android:shape="rectangle" >
    <gradient
        android:angle="270"
        android:centerColor="#000000"
        android:endColor="#F6F6F6"
        android:startColor="#F6F6F6" />
</shape>

布局

<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:id="@+id/scroll_container"
    android:layout_width="fill_parent"
    android:layout_height="fill_parent"
    android:background="@android:color/white"
    android:splitMotionEvents="false" >
    <View
        android:id="@+id/divider"
        android:layout_width="1dp"
        android:layout_height="fill_parent"
        android:layout_centerHorizontal="true"
        android:background="@drawable/backgrad" />
</RelativeLayout>

我希望这可以帮助你。

I hope this can help you out.

感谢。

这篇关于GridView控件之间的渐变线条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆