android浏览控件
⑴ 最新的Android控件有哪些
1.MaterialStepperView
它是用Material Design实现Steppers的。
目前,Stepper只有垂直视图,但将来会有更多的风格。你可以尝试一下,如下图:
你可以自定义normal/active两个状态的颜色,完成图标,开启动画并设置动画时长。可通过Github上的设置项和样式查阅所有设置项。该库支持API 17+,详情请查阅wiki文档。
2. MultiSnapRecyclerView
这是分屏滚动的Android库。
MultiSnapRecyclerView为RecyclerView提供了分屏功能。
目前提供的功能有:
start, end和center三个位置的吸附,
snap count 指定要分屏的数量,
支持水平和垂直分屏,
滚动时的回调。
3. Garland View for Android
该库可实现如下的布局:
GarlandView 外部是一个水平滚动的视图,视图内的每一个子视图可垂直滚动。
你可以在README中找到其他重要信息。还有一个示例App。该库支持API 19及更高版本。
4. VegaLayoutManager
这是一个自定义的布局管理器——滚动时缩小并淡出头部。这是受到Dribble项目的启发。
5. ExpandableLayout
这个库的名字不言而喻,它是一个基于LinearLayout的可扩展的布局。
README里含有你启动时需要的所有信息,另外,还有一个示例App可以帮助你快速跳转到代码中。
6. SwipeBackLayout
SwipeBackLayout允许你使用手势返回上一个界面。
你可以设置滑动方向,如从左到右、从右到左、从顶部到底部、从底部到顶部。
你还可以设置是否只能从边缘滑动。
SwipeBackLayout只能包含一个子布局,例如:
LinearLayout,RelativeLayout,FrameLayout,TableLayout等。
ScrollView,HorizontalScrollView,NestedScrollView等。
RecyclerView,AbsListView(ListView)等子类。
ViewPager,WebView等。
该项目里面有一个详细说明的文档、示例APP和一个APK。
⑵ android界面控件
PopupWindow类,你网上搜索一下使用方法!
⑶ android怎么获取 中的控件
在实际开发中LayoutInflater这个类还是非常有用的,它的作用类似于findViewById()。不同点是LayoutInflater是用来找res/layout/下的xml布局文件代码块,并且实例化;而findViewById()是找xml布局文件下的具体widget控件(如Button、TextView等)。 具体作用:
1、对于一个没有被载入或者想要动态载入的界面,都需要使用LayoutInflater.inflate()来载入;
2、对于一个已经载入的界面,就可以使用Activiyt.findViewById()方法来获得其中的界面元素。
LayoutInflater 是一个抽象类,在文档中如下声明:
public abstract class LayoutInflater extends Object
获得 LayoutInflater 实例的三种方式:
1.LayoutInflater inflater = getLayoutInflater(); //调用Activity的getLayoutInflater()
2.LayoutInflater localinflater =(LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
1. LayoutInflater inflater = LayoutInflater.from(context);
其实,这三种方式本质是相同的,从源码中可以看出:
getLayoutInflater():
Activity 的 getLayoutInflater() 方法是调用 PhoneWindow 的getLayoutInflater()方法,看一下该源代码:
public PhoneWindow(Context context) {
super(context);
mLayoutInflater = LayoutInflater.from(context);
}
可以看出它其实是调用 LayoutInflater.from(context)。
LayoutInflater.from(context):
public static LayoutInflater from(Context context) {
LayoutInflater LayoutInflater = (LayoutInflater) context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
if (LayoutInflater ==null) {
throw new AssertionError("LayoutInflater not found.");
}
return LayoutInflater;
}
可以看出它其实调用 context.getSystemService()。
结论:所以这三种方式最终本质是誉基胡都是调庆拦用的Context.getSystemService()。锋伍
inflate 方法 通过 sdk 的 api 文档,可以知道该方法有以下几种过载形式,返回值均是 View 对象,如下:
public View inflate (int resource, ViewGroup root);
3 public View inflate (XmlPullParser parser, ViewGroup root);
4 public View inflate (XmlPullParser parser, ViewGroup root, boolean attachToRoot);
5 public View inflate (int resource, ViewGroup root, boolean attachToRoot);
6
7 LayoutInflater inflater = (LayoutInflater)getSystemService(LAYOUT_INFLATER_SERVICE);
8 View view = inflater.inflate(R.layout.custom, (ViewGroup)findViewById(R.id.test));
9 //EditText editText = (EditText)findViewById(R.id.content);
10 // error
EditText editText = (EditText)view.findViewById(R.id.content);
对于上面代码,指定了第二个参数 ViewGroup root,当然你也可以设置为 null 值。
注意:
·inflate方法与 findViewById 方法不同;
·inflater 是用来找 res/layout下的 xml 布局文件,并且实例化;
·findViewById() 是找具体 xml 布局文件中的具体 widget 控件(如:Button、TextView 等)。