Mat*_*att 7 java android border scrollview
我的问题是,如果有一种方法可以在一个简单的黑线边框周围放置一个简单的黑线边框,ScrollView那么用户就可以准确地知道它的ScrollView起点,停止点和宽度.我在Android文档中找不到任何类型的XML或Java代码,说明如何执行此操作.我知道这必须是可能的.
下面是我ScrollView需要有边框的XML代码.
<LinearLayout
.... />
<TextView
... />
//BORDER STARTS HERE
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="94.5"
android:paddingBottom="5dp"
android:fillViewport="true" >
<LinearLayout
... >
<TextView
... />
</LinearLayout>
</ScrollView>
//BORDER ENDS HERE
<Button
... />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
编辑
我刚刚添加了一个scrollviewborder.xml以下代码作为背景ScrollView.
<?xml version="1.0" encoding="utf-8"?>
<shape
xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="2dp"
android:color="#000000"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
下面的截图是它产生的:

这不是我想要的.我想要一条薄的黑线,而不是一个黑盒子.
Sea*_*ole 11
根据您的新要求,请尝试以下代码:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<solid
android:color="@android:color/transparent"/>
<stroke
android:width="2dp"
android:color="#000000"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
例:
<ScrollView
android:layout_width="fill_parent"
android:layout_height="0dip"
android:layout_weight="94.5"
android:paddingBottom="5dp"
android:background="@drawable/stroke_bg"
android:fillViewport="true" >
Run Code Online (Sandbox Code Playgroud)
在drawables文件夹中,有一个stroke_bg.xml文件:
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">
<stroke
android:width="2dp"
android:color="#000000"/>
</shape>
Run Code Online (Sandbox Code Playgroud)
这将导致滚动视图的黑色边框宽度为2dp.
| 归档时间: |
|
| 查看次数: |
8521 次 |
| 最近记录: |