Android的 - 用点水平进度条 [英] Android - Horizontal progress bar with dots

查看:154
本文介绍了Android的 - 用点水平进度条的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有用户应答的形式问题的项目。
我需要实现的水平进度条(而不是一个对话框),用点而不是正常的吧。

I have a project that the user answers questions in a form. I need to implement a horizontal progress bar (not a dialog), with dots instead the normal bar.

当用户回答一个问题,具体问题的点改变了颜色。
这是可能的吗?我使用的是API 16(目标)和API 7(最低要求)与福尔摩斯动作条

When the user answers a question, the dot of that specific question changes the color. This is possible? I'm using API 16 (target) and API 7 (minimum) with Sherlock ActionBar

推荐答案

XML:

<LinearLayout
    android:id="@+id/image_layout"
    android:orientation="horizontal" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content"
    android:layout_gravity="center_vertical">

动态添加图片和隐藏他们(基于问题的总数),我也把layout_weight等于1,你可以看到,所以每个点有相同的尺寸:

Adding pictures dynamically and hiding them (based on total number of questions), I also put the layout_weight equal to 1 as you can see, so each "dot" has the same size:

ImageView[] images = new ImageView[totQuestions];
LinearLayout imageLayout = (LinearLayout) findViewById(R.id.image_layout);  
ImageView image;
LinearLayout.LayoutParams layoutParams;
for(int i = 0; i < totQuestions; i++){
    image = new ImageView(this);
    layoutParams = new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1.0f);
    image.setLayoutParams(layoutParams);
    image.setBackgroundDrawable(getResources().getDrawable(R.drawable.circle_green));
    image.setVisibility(View.INVISIBLE);
    images[i] = image;
    imageLayout.addView(image);
}

每个回答后,显示图片:

Showing pictures after each answer:

imageLayout.getChildAt(questionNr).setVisibility(View.VISIBLE); //starting at 0

我只是改进的地方的 slezadav 建议。

这篇关于Android的 - 用点水平进度条的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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