Android的磨损WearableListView ImageView的选择 [英] Android wear WearableListView ImageView selector
问题描述
我想创建一个列表视图,如下所示: -
I am trying to create a list view as follows:-
现在,我成功地使用WearableListView适配器所做的列表视图的工作。但是,我使用的静态图像的ImageView的。我想要的是创建这个灰色和蓝色样的动画时,滚动时的特定列表元素集中。我怎么做?我试着用了ImageView的一个选择器的XML文件,但看来这ListView的犯规利用这个选择器(安卓州为中心,选择,pressed,没有任何工程)的。任何想法,我怎么得到我想要的?希望我做了我的问题清楚。谢谢你。
Now, I have made the list view work successfully using the WearableListView adapter. However, I am using static images in the ImageView. What I want is to create this gray and blue kind of animation when a particular list element is focused while scrolling. How do I do that? I tried using a selector xml file for the ImageView but it seems this ListView doesnt make use of this selector(android:state-focused, selected, pressed-nothing works). Any idea how do I get what I want? Hope I made my question clear. Thanks.
推荐答案
是的,你说得对,图像选择不工作,为什么?我不知道到底,我们不会对任何文档阅读。
Yes you are right, image selector doesn't work, why? I don't know exactly and we don't have any documentation on it to read.
但幸运的是我已经成功地实现了这一局面,它几乎类似于默认设置屏幕。
But fortunately I have implemented this scenario successfully and it's almost similar to the default settings screen.
有关解决办法,我已经建立圈子里面的颜色下面的方法:
For workaround, I have set circle color inside below methods:
-
onScaleUpStart()
- 集圈颜色选择的项目 -
onScaleDownStart()
- 集圈颜色非选择项
onScaleUpStart()
- Set circle color for selected itemonScaleDownStart()
- Set circle color for non-selected items.
我已经采取CircleImageView和TextView中我的项目布局中。例如code可能是:
I have taken CircleImageView and TextView inside my item layout. Example code could be:
private final class MyItemView extends FrameLayout implements WearableListView.Item {
final CircledImageView image;
final TextView text;
private float mScale;
private final int mFadedCircleColor;
private final int mChosenCircleColor;
public MyItemView(Context context) {
super(context);
View.inflate(context, R.layout.wearablelistview_item, this);
image = (CircledImageView) findViewById(R.id.image);
text = (TextView) findViewById(R.id.text);
mFadedCircleColor = getResources().getColor(android.R.color.darker_gray);
mChosenCircleColor = getResources().getColor(android.R.color.holo_blue_dark);
}
@Override
public float getProximityMinValue() {
return mDefaultCircleRadius;
}
@Override
public float getProximityMaxValue() {
return mSelectedCircleRadius;
}
@Override
public float getCurrentProximityValue() {
return mScale;
}
@Override
public void setScalingAnimatorValue(float value) {
mScale = value;
image.setCircleRadius(mScale);
image.setCircleRadiusPressed(mScale);
}
@Override
public void onScaleUpStart() {
image.setAlpha(1f);
text.setAlpha(1f);
image.setCircleColor(mChosenCircleColor);
}
@Override
public void onScaleDownStart() {
image.setAlpha(0.5f);
text.setAlpha(0.5f);
image.setCircleColor(mFadedCircleColor);
}
}
这篇关于Android的磨损WearableListView ImageView的选择的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!