androidview线
⑴ android怎么实现textview后面有条线
设置textview的格式 可以设置下划线,删除线 等等格式
textview.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG |Paint.ANTI_ALIAS_FLAG);
⑵ android textview两侧贯穿线怎么做啊
是文字上的横线吧?类似于eclipse中一些过时方法的样子?
如果是这样设置就行了:tv.getPaint().setFlags(Paint. STRIKE_THRU_TEXT_FLAG );
⑶ android自定义view的参数传递问题
android自定义view的参数传递,自定义View细分一下,分为两种
1) 自定义ViewGroup
2) 自定义View
其实ViewGroup最终还是继承之View,当然它内部做了许多操作;继承之ViewGroup的View我们一般称之为容器,而今天我们不讲这方面,后续有机会再讲。
来看看自定义View 需要掌握的几点,主要就是两点
一、重写 protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {}方法。
二、重写 protected void onDraw(Canvas canvas) {}方法
空讲理论很难理解,还得用例子来说明, Android 微信6.1 tab栏图标和字体颜色渐变的实现 的博客,里面tab的每个item就是通过自定义View来实现的,那么接下来就通过此例子来说明问题。
把View理解为一张白纸,而自定义View就是在这张白纸上画上我们自己绘制的图案,可以在绘制任何图案,也可以在白纸的任何位置绘制,那么问题来了,白纸哪里来?图案哪里来?位置如何计算?
a)白纸好说,只要继承之View,在onDraw(Canvas canvas)中的canvas就是平常规裁军所说的白纸
/**
* Created by moon.zhong on 2015/2/13.
*/
public class CustomView extends View {
public CustomView(Context context) {
super(context);
}
public CustomView(Context context, AttributeSet attrs) {
super(context, attrs);
⑷ android中的View是做什么的
View类是Android的一个超类,这个类几乎包含了所有的屏幕类型。每一个View都有一个用于绘图的画布,这个画布可以进行任意扩展。在游戏开发中叶可以自定义视图(View),这个画布的功能更能满足我们在游戏开发中的需要。在Android中,任何一个View类都只需重写onDraw 方法来实现界面显示,自定义的视图可以是复杂的3D实现,也可以是非常简单的文本形式等。
⑸ android中如何利用view视图添加一条直线
你好!
步骤1:在你创建的工程中新建一个class文件,随便起个名字叫MyView吧,打开文件会看到:
public
class
MyView
{
}
步骤2:让该类继承
View类,也就是在MyView后面添几个字母,如:
public
class
MyView
extends
View
{
}
步骤3:在上面的这个类中,写一个方法:
public
class
MyView
extends
View
{
protected
void
onDraw(Canvas
canvas)
{
..........
}
}
步骤4:在onDrow方法中写一条语句:
public
class
MyView
extends
View
{
protected
void
onDraw(Canvas
canvas)
{
canvas.drawLine(起点横坐标,起点纵坐标,终点横坐标,终点纵坐标,线的颜色);
}
}
注:看到“drawLine”了吧,这就是在画线。
如有疑问,请追问。
⑹ java 中,android 在一个view上绘制多条线 如何点击一条线,改变这条线的颜色。
解决这个问题的核心是你怎么知道那条线被点击了,首先要给View设置一个onTouchListener,然后获取点击的坐标,然后判断手指在屏幕上的坐标是不是在你的线条所在的区域,这个区域的大小又你来定义。如果是,那么你就改变paint的颜色这,然后调用invalidate()来通知VIew进行重绘。
⑺ android 用xml资源 给view设置边界线却不显示是什么原因
双方互评后才会显示评价内容的,他现在还没有给你评价,评价是不会生效的哦。。如果当初您要求退换货他不同意的话,您该投诉他的。评价显示了的话,卖家又会找你麻烦了,也许还要给你一个差评还是要闹到投诉的。。。哎。。为什么淘宝那么多无良卖家呢。我曾经也被骗过哎,可惜投诉无门啊,那个人就是骗子也没加消保。骗了一笔钱就溜之大吉了。所以,奉劝各位买家淘宝购物一定要擦亮双眼,看有没有品质保证,不要贪图便宜,否则只能吃亏。
⑻ android viewpagerindicator指示线不显示什么问题
使用ViewPager的setCurrentItem (int item) 方法设置其初始显示的页面,不是在其数据适配器中,而是在完成数据适配后设置。如viewPager.setAdapter(adapter);viewPager.setCurrentItem(3);
⑼ android中, 在一个View上画多条线(一条线是一个实体对象),怎样给这些线添加click事件
使用linearlayout画这条线(即高度设置为1dp或其他,改linearlayout的背景颜色),为改linearlayout注册onclick事件.
大致就是这样.
⑽ 如何创建一个View的分割线
1 人工添加LinearLayout的分割线
我们可以创建一个View,这个View就是分割线,只要简单在Button之间添加这个分割线就可以。
分割线的实现,如下:
<View android:layout_height="fill_parent" android:layout_width="1dp" android:background="#90909090" android:layout_marginBottom="5dp" android:layout_marginTop="5dp"/>So the whole layout, as pictured, becomes:
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:orientation="horizontal"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Yes" android:layout_weight="1" android:id="@+id/button1" android:textColor="#00b0e4" /> <View android:layout_height="fill_parent" android:layout_width="1px" android:background="#90909090" android:layout_marginBottom="5dp" android:layout_marginTop="5dp" android:id="@+id/separator1" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="No" android:layout_weight="1" android:id="@+id/button2" android:textColor="#00b0e4" /> <View android:layout_height="fill_parent" android:layout_width="1px" android:background="#90909090" android:layout_marginBottom="5dp" android:layout_marginTop="5dp" android:id="@+id/separator2" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Neutral" android:layout_weight="1" android:id="@+id/button3" android:textColor="#00b0e4" /> </LinearLayout>2 在LinearLayout定义divider
你可以给LinearLayout设置a view divider,这很明显是个很好的解决方法,尤其是不知道LinearLayout下有多少个子Button。
这种必须是在API level 11 或者更高的API版本使用。
我们先定义这个分割线样式吧:
<?把这个分割线的样式设置给LinearLayout:
<LinearLayout android:layout_width="fill_parent" android:layout_height="wrap_content" android:adjustViewBounds="true" android:divider="@drawable/separator" android:showDividers="middle" android:orientation="horizontal"> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Yes" android:layout_weight="1" android:id="@+id/button1" android:textColor="#00b0e4" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="No" android:layout_weight="1" android:id="@+id/button2" android:textColor="#00b0e4" /> <Button android:layout_width="fill_parent" android:layout_height="wrap_content" android:text="Neutral" android:layout_weight="1" android:id="@+id/button3" android:textColor="#00b0e4" /> </LinearLayout>其中最重要当然就是:
android:divider="@drawable/separator"android:showDividers="middle"
3给容器组件设置ButtonBarStyle (默认是分割线,最容易实现方法)
As danialgoodwin mentioned in the comments, adding the buttonBarStyle to the LinearLayout will show default separators. This is also for api level 11 or higher only.
The important part here, is adding this line to the LinearLayout:
<LinearLayout android:orientation="horizontal" android:layout_width="fill_parent" android:layout_height="fill_parent" android:dividerPadding="15dp" > <Button android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="New Button" android:id="@+id/button1" android:layout_gravity="center_vertical" /> <!-- more buttons/views --> </LinearLayout>You can also adjust the paddings of the view separators with the “dividerPadding” setting.
Button使用的相同的检举,所以他们之间的间距也是相同的。
当然你可为分割线设置渐变色。
转载仅供参考,版权属于原作者。祝你愉快,满意请采纳哦