CoordinatorLayout 在获取fragment中的控件不支持吗

Android 教你使用CoordinatorLayout
在API Level 21及更高版本,为了支持NestedScrolling,所有控件的基类View对外新增了一个方法setNestedScrollingEnabled(boolean enabled),所以,我们可以对ListView稍作处理,就能在Android L及以上版本的系统中使用了: if (Build.VERSION.SDK_INT &= Build.VERSION_CODES.LOLLIPOP) {
listView.setNestedScrollingEnabled(true);}我知道大家肯定要问了,有何良方可以兼容更低版本的系统呢?聪明如我,还记得以前的博客中提到的v4包中的ViewCompat类吗!它可是个好东西,总是能在兼容的问题上救民于水火,这不,这里又有解决方案啦: ViewCompat.setNestedScrollingEnabled(listView, true);这样做,就可以在所有系统中使用ListView来配合CoordinatorLayout。但是,ListView真的已经过气了,我们应该全方位掌握RecyclerView的使用,就像Android Studio取代Eclipse一样。其他的代码就很简单了,就是给DrawerLayout设置ActionBarDrawerToggle,就是图中ToolBar左侧的菜单按钮。然后用Fragment填充ViewPager,这里就不贴代码了,工程Demo都在GitHub上,大家可以自己下载参考。其实这个案例的实现还是蛮简单的,文中零零碎碎地讲述了很多使用过程中的细节技巧,帮助大家解决实际问题。下篇文章继续使用案例,介绍CoordinatorLayout的使用方法,同时引入另一个控件的使用,欢迎关注! 示例源码我在GitHub上建立了一个Repository,用来存放整个Android Material Design系列控件的学习案例,会伴随着文章逐渐更新完善,欢迎大家补充交流,Star地址:/Mike-bel/MDStudySamples
娱乐圈里真是热闹,前有凤姐元在异国他乡为王宝强声援,后有国内芙蓉姐姐为宝宝排忧解难大支招。
&来源:大河网
日,刘伶利发在微信朋友圈中的自拍照。8月16日,刘伶利去世第三天,她的母亲刘淑琴整理女儿患病期间摆摊用的衣架。
&来源:中国青年报
还是搜狐好,之前在猫扑发过天葬的照片,我可是怀着敬畏之情,并无歧视之意,没想到无法通过审核。不多说,先来几张照片。修建中的天葬台。
&来源:快站
体育之窗的钱都去哪了? 7月25日,本应在鸟巢举办的“2016国际冠军杯中国赛北京站曼城与曼联”的比赛在开赛4小时前被取消...
&来源:金融街侦探
水浒传里谁最厉害呢?很多人的答案都不一样。因为梁山好汉中厉害的人太多了。水浒传里谁最厉害?那还得看是什么方面,每个英雄好汉都有自己的绝活...
&来源:光明网
时间真快,不知不觉中悄然向9月迈进。手机市场在这8月中也依旧火热,小编发展,有4款手机在8月中特别抢手,其不但颜值高,配置也相当不错...
&来源:一点资讯
对于这个问题,从本质上来看,是无解的,客观原因有以下几点:1、中国智能手机市场够大,足够容得下OPPO和华为两个甚至多个巨头的同时存在。
&来源:头条问答
王宝强离婚事件闹的沸沸扬扬,但凡一点儿风吹草动都会引来大量网友关注。现在,一部名为《宝宝别哭》的网络大电影已经开机...
&来源:环球网
食人鱼在世人眼中是很可怕的鱼类,他们具有比一般鱼类还要大的牙齿、总是群体行动,朝目标发动攻击后短时间内就会被他们啃光了。
&来源:光明网
据了解,此项目施行后,乘客无需预先购票或者充值交通卡,并且使用银联IC卡“闪付”过闸有5折优惠,而银联“云闪付”过闸也有1折优惠...
&来源:亿邦动力网
8月16日北京乐视体育生态中心,全新cool1手机正式发布,一同亮相的还有原荣耀CEO刘江峰,如今他身份变成酷派集团CEO...
&来源:神猴数码
腾讯科学讯 据英国每日邮报报道,如果你想获得更多的性生活,不必在意自己的身材,或者购买性感内衣。
&来源:腾讯科学
Ctrl+D&将本页面保存为书签,全面了解最新资讯,方便快捷。CoordinatorLayout简介
时间: 15:59:55
Material Design (四),AppBarLayout的使用前言&&&&?AppBarLayout,顾名知意,就是用来给AppBar布局的容器,是LinearLayout的子类。而AppBar就包含我们通常所知道的ActionBar,Toolbar。&&&&AppBarLayout要点:&&&&&&&&功能:让子View(AppBar)可以选择他们自己的滚动行为。&&&&注意:需要依赖CoordinatorLayout作为父容器,同时也要求一个具有可以独立滚动的兄弟节点(或兄弟节点的子view可以滚动)才能发挥其功能。&&&&&&&&CoordinatorLayout简介:&&&&?该控件是Design包下的一个控件,是组织它众多子view之间互相协作的一个ViewGroup。CoordinatorLayout 的神奇之处就在于 Behavior 对象。CoordinatorLayout使用 Behavior 对象进行通信,使得其子view之间知道了彼此的存在,一个子view的变化可以通知到另一个子view。CoordinatorLayout 所做的事情就是当成一个通信的桥梁,连接不同的view。&&&&使用该控件需要依赖相关的库:&&&&dependencies {&&&&
compile fileTree(dir: 'libs', include: ['*.jar'])&&&&
compile 'com.android.support:appcompat-v7:23.0.1'&&&&
compile 'com.android.support:design:23.0.1'&&&&}&&&&实践出真章,动手才是硬道理&&&&1. Toolbar + AppBarLayout的简单例子&&&&?前面已经说了,AppBarLayout需要CoordinatorLayout作为父容器并且还需要一个可以独立滚动的兄弟节点(CoordinatorLayout 的子view(或间接子view))才能发挥其功能,不多说,看下面的布局:&&&&activity_main.xml&&&&&?xml version="1.0" encoding="utf-8"?&&&&&
xmlns:android="/apk/res/android"&&&&
xmlns:app="/apk/res-auto"&&&&
xmlns:tools="/tools"&&&&
android:layout_width="match_parent"&&&&
android:layout_height="match_parent"&&&&
tools:context="com.example.lt.appbarlayoutdemo.MainActivity"&&&&&
android:layout_width="match_parent"&&&&
android:fitsSystemWindows="true"&&&&
android:layout_height="wrap_content"&&&&
android:id="@+id/toolbar"&&&&
android:layout_width="match_parent"&&&&
android:layout_height="?attr/actionBarSize"&&&&
android:background="?attr/colorPrimary"&&&&
app:layout_scrollFlags="scroll|enterAlways"&&&&
app:popupTheme="@style/AppTheme.PopupOverlay"/&&&&&
android:layout_width="match_parent"&&&&
android:layout_height="match_parent"&&&&
app:layout_behavior="@string/appbar_scrolling_view_behavior"&&&&&
android:layout_width="match_parent"&&&&
android:layout_margin="20dp"&&&&
android:text="日本疑似被绑架记者现身网络中国新闻网 18:55"&&&&
android:layout_height="wrap_content"/&&&&&
&&&&&&&&&&注意:&&&&&&&&兄弟节点的app:layout_behavior="@string/appbar_scrolling_view_behavior"属性很重要;&&&&AppBarLayout子view的app:layout_scrollFlags属性很重要,其值有三个: &&&&scroll: 所有想滚动出屏幕的view都需要设置这个flag- 没有设置这个flag的view将被固定在屏幕顶部。&&&&enterAlways: 这个flag让任意向下的滚动都会导致该view变为可见,启用”快速返回”模式。&&&&enterAlwaysCollapsed: 当你的视图已经设置minHeight属性又使用此标志时,你的视图只会在最小高度处进入,只有当滚动视图到达顶部时才扩大到完整高度。&&&&exitUntilCollapsed: 在滚动过程中,只有当视图折叠到最小高度的时候,它才退出屏幕。&&&&注意AppBarLayout的兄弟节点(或兄弟节点的子view)一定要是可以滚动的View/ViewGroup,如:NestedScrollView,RecycleView;&&&&那些使用Scroll flag的视图必须在其他没有使用Scroll flag的视图之前声明。这样才能确保所有的视图从顶部撤离,剩下的元素固定在前面(译者注:剩下的元素压在其他元素的上面)。&&&&&&&&Activity代码测试:&&&&package com.example.lt.&&&&import android.os.B&&&&import android.support.design.widget.FloatingActionB&&&&import android.support.design.widget.S&&&&import android.support.v7.app.AppCompatA&&&&import android.support.v7.widget.T&&&&import android.view.V&&&&import android.view.M&&&&import android.view.MenuI&&&&import android.widget.ArrayA&&&&import android.widget.ListV&&&&public class MainActivity extends AppCompatActivity {&&&&
@Override&&&&
protected void onCreate(Bundle savedInstanceState) {&&&&
super.onCreate(savedInstanceState);&&&&
setContentView(R.layout.activity_main);&&&&
Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);&&&&
setSupportActionBar(toolbar);&&&&
@Override&&&&
public boolean onCreateOptionsMenu(Menu menu) {&&&&
getMenuInflater().inflate(R.menu.menu_main, menu);&&&&
return true;&&&&
@Override&&&&
public boolean onOptionsItemSelected(MenuItem item) {&&&&
int id = item.getItemId();&&&&
if (id == R.id.action_settings) {&&&&
return true;&&&&
return super.onOptionsItemSelected(item);&&&&
}&&&&}&&&&关于Toolbar的使用可以参考:android 5.X Toolbar+DrawerLayout实现抽屉菜单,这里就不多做说明了。&&&&2. 再 + TabLayout实现经典组合&&&&activity_main.xml&&&&&?xml version="1.0" encoding="utf-8"?&&&&&
xmlns:android="/apk/res/android"&&&&
xmlns:app="/apk/res-auto"&&&&
xmlns:tools="/tools"&&&&
android:layout_width="match_parent"&&&&
android:layout_height="match_parent"&&&&
tools:context="com.example.lt.appbarlayoutdemo.MainActivity"&&&&&
android:layout_width="match_parent"&&&&
android:fitsSystemWindows="true"&&&&
android:layout_height="wrap_content"&&&&
android:id="@+id/toolbar"&&&&
android:layout_width="match_parent"&&&&
android:layout_height="?attr/actionBarSize"&&&&
android:background="?attr/colorPrimary"&&&&
app:layout_scrollFlags="scroll|enterAlways"&&&&
app:popupTheme="@style/AppTheme.PopupOverlay"/&&&&&
android:id="@+id/tablayout"&&&&
android:layout_width="match_parent"&&&&
android:layout_height="wrap_content"&&&&
app:layout_scrollFlags="scroll|enterAlways"&&&&
app:tabIndicatorColor="@android:color/transparent"&&&&
app:tabMode="scrollable"&&&&&
android:id="@+id/viewPager"&&&&
app:layout_behavior="@string/appbar_scrolling_view_behavior"&&&&
android:layout_width="match_parent"&&&&
android:layout_height="match_parent"&&&&
&&&&&&&&&&初始化TabLayout&&&&String[] titles = {"最新","赣州","社会","订阅","娱乐","NBA","搞笑","科技","创业"};&&&&ViewPager viewPager = (ViewPager) findViewById(R.id.viewPager);&&&&List&Fragment& fragments = new ArrayList&Fragment&();&&&&for (int i = 0; i & titles. i++) {&&&&
Fragment fragment = new MyFragment();&&&&
Bundle bundle = new Bundle();&&&&
bundle.putString("text",titles[i]);&&&&
fragment.setArguments(bundle);&&&&
fragments.add(fragment);&&&&}&&&&viewPager.setAdapter(new TabFragmentAdapter(fragments, titles, getSupportFragmentManager(), this));&&&&&&&&TabLayout tablayout = (TabLayout) findViewById(R.id.tablayout);&&&&&&&&tablayout.setupWithViewPager(viewPager);&&&&&&&&tablayout.setTabTextColors(Color.GRAY, Color.WHITE);&&&&MyFragment.java&&&&package com.example.lt.&&&&import android.graphics.C&&&&import android.os.B&&&&import android.support.annotation.N&&&&import android.support.v4.app.F&&&&import android.support.v4.view.ViewP&&&&import android.support.v4.widget.NestedScrollV&&&&import android.view.G&&&&import android.view.LayoutI&&&&import android.view.V&&&&import android.view.ViewG&&&&import android.widget.TextV&&&&/**&&&& * Created by lt on .&&&& */&&&&public class MyFragment extends Fragment {&&&&
private String mT&&&&
@Override&&&&
public void onCreate(@Nullable Bundle bundle) {&&&&
super.onCreate(bundle);&&&&
if(getArguments()!=null){&&&&
mText = getArguments().getString("text");&&&&
@Nullable&&&&
@Override&&&&
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {&&&&
NestedScrollView scrollableView = new NestedScrollView(getActivity());&&&&
TextView textView = new TextView(getActivity());&&&&
textView.setTextColor(Color.RED);&&&&
textView.setGravity(Gravity.CENTER);&&&&
textView.setText(mText);&&&&
scrollableView.addView(textView);&&&&
return scrollableV&&&&
}&&&&}&&&&需要注意的是,我们无论如何都要给AppBarLayout添加一个可以滚动的的兄弟节点(或兄弟节点的子节点),这里就嵌套了NestedScrollView 。&&&&TabFragmentAdapter.java&&&&package com.example.lt.&&&&import android.content.C&&&&import android.support.v4.app.F&&&&import android.support.v4.app.FragmentM&&&&import android.support.v4.app.FragmentPagerA&&&&import java.util.L&&&&/**&&&& * Created by lt on .&&&& */&&&&public class TabFragmentAdapter extends FragmentPagerAdapter{&&&&
private final String[]&&&&
private C&&&&
private List&Fragment&&&&&
public TabFragmentAdapter(List&Fragment& fragments,String[] titles, FragmentManager fm, Context context) {&&&&
super(fm);&&&&
this.context =&&&&
this.fragments =&&&&
this.titles =&&&&
@Override&&&&
public Fragment getItem(int position) {&&&&
return fragments.get(position);&&&&
@Override&&&&
public int getCount() {&&&&
return titles.&&&&
@Override&&&&
public CharSequence getPageTitle(int position) {&&&&
return titles[position];&&&&
}&&&&}&&&&关于TabLayout的使用不懂的可以参考:TabLayout轻松实现仿今日头条顶部tab导航效果&&&&Toolbar和TabLayout布局属性layout_scrollFlags值组合:&&&&&&&&(1)Toolbar=scroll|enterAlways &&&&(2)TabLayout=scroll|enterAlways&&&&效果:&&&&&&&&(1)Toolbar=scroll|enterAlways &&&&(2)TabLayout不设该属性&&&&效果:&&&&&&&&(1)Toolbar=不设该属性 &&&&(2)TabLayout不设该属性&&&&效果:&&&&&&&&即不会滑出屏幕&&&&(1)Toolbar不设该属性 &&&&(2)TabLayout=scroll|enterAlways&&&&效果:&&&&&&&&即不会滑出屏幕&&&&&&&&总结:关于这些控件的使用,我认为不必一次性全部学透,只要我们会个大概的使用就行了,其他更加细节的东西(比如Toolbar修改样式等等)可以等用到的时候再去研究。因为,有些控件要一次学透比较费时间,还说不定以后用不到。比如:学习ActionBar的时候没必要先去知道怎么修改ActionBar的背景颜色,等我们使用ActionBar有这方面的需要的时候再去研究,查找解决方法。&&&&需要源码的请点击下面的链接:&&&&demo下载android开发步步为营之71:CoordinatorLayout+AppBarLayout+RecyclerView+ViewPager打造可上下左右滑动的App主框架
日期: 17:08:10
来源:ITeye
android开发步步为营之71:CoordinatorLayout+AppBarLayout+RecyclerView+ViewPager打造可上下左右滑动的App主框架
在看过很多app之后,你会发现现在很多的app的主框架是可以上下左右滑动,左右滑动,我们自然会想到用viewpager,但是上下可以滑动,而且顶部广告或者背景划上去之后,还需要保留tab标签用什么来实现?查阅过很多资料,最终发现sdk里面android support v7有CoordinatorLayout+AppBarLayout+RecyclerView,两个组件组合可以支持上下滑动效果,另外CoordinatorLayout+AppBarLayout+NestedScrollView也可以实现上下滑动效果,但是经试验证明,NestedScrollView需要本身可以滑动,也就是里面的数据超过满屏需要滑动,才能将AppBarLayout划上去。
先给出效果图,不好意思,不知道怎么弄动态图,给出两张静态效果图。
OK,现在我们来实现这个功能,这里给出主要的步骤。
第一步:引入V7的支持库
build.gradle里面引入
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:design:22.2.0'
compile 'com.android.support:recyclerview-v7:22.2.0'
第二步:设计主页面activity_main.xml
&?xml version="1.0" encoding="utf-8"?&
&android.support.design.widget.CoordinatorLayout
android:id="@+id/main_content"
xmlns:android="/apk/res/android"
xmlns:app="/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"&
&android.support.design.widget.AppBarLayout
android:id="@+id/appbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"&
&LinearLayout
android:id="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="100dp"
android:background="#123456"
app:layout_scrollFlags="scroll|enterAlways"
app:popupTheme="@style/ThemeOverlay.AppCompat.Light"
android:gravity="center_vertical"
android:orientation="vertical"&
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="the best app"/&
&/LinearLayout&
&android.support.design.widget.TabLayout
android:id="@+id/tabs"
android:layout_width="match_parent"
android:layout_height="40dp"
android:background="#810e88"/&
&/android.support.design.widget.AppBarLayout&
&android.support.v4.view.ViewPager
android:id="@+id/vp_body"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:layout_behavior="@string/appbar_scrolling_view_behavior"&
&/android.support.v4.view.ViewPager&
&/android.support.design.widget.CoordinatorLayout&
第三步:编写MainActivity.java
package com.figo.
import android.os.B
import android.support.design.widget.TabL
import android.support.v4.app.F
import android.support.v4.app.FragmentA
import android.support.v4.app.FragmentM
import android.support.v4.app.FragmentPagerA
import android.support.v4.view.ViewP
import android.util.L
import android.view.V
import com.figo.study.fragment.ActivityF
import com.figo.study.fragment.ExchangeF
import com.figo.study.fragment.MeF
import java.util.ArrayL
import java.util.L
public class MainActivity extends FragmentActivity {
private ViewPager mVpB
ArrayList&Fragment& fragmentsL
private int currI
List&String&
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
initViewPager();
private void initViewPager() {
TabLayout mTabLayout = (TabLayout) findViewById(R.id.tabs);
titles = new ArrayList&&();
titles.add("Exchange");
titles.add("Activity");
titles.add("Me");
mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(0)));
mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(1)));
mTabLayout.addTab(mTabLayout.newTab().setText(titles.get(2)));
mTabLayout.setTabTextColors(getResources().getColor(R.color.white), getResources().getColor(R.color.selected));
mVpBody = (ViewPager) findViewById(R.id.vp_body);
fragmentsList = new ArrayList&Fragment&();
Bundle bundle = new Bundle();
Fragment exchangeFragment = ExchangeFragment.newInstance(
MainActivity.this, bundle);
Fragment activityFragment = ActivityFragment.newInstance(
MainActivity.this, bundle);
Fragment meFragment = MeFragment.newInstance(
MainActivity.this, bundle);
fragmentsList.add(exchangeFragment);
fragmentsList.add(activityFragment);
fragmentsList.add(meFragment);
TabFragmentPagerAdapter tabFragmentPagerAdapter = new TabFragmentPagerAdapter(
getSupportFragmentManager(), fragmentsList);
mVpBody.setAdapter(new TabFragmentPagerAdapter(
getSupportFragmentManager(), fragmentsList));
mVpBody.setCurrentItem(0);
mVpBody.setOnPageChangeListener(new MyOnPageChangeListener());
mTabLayout.setupWithViewPager(mVpBody);
mTabLayout.setTabsFromPagerAdapter(tabFragmentPagerAdapter);
} catch (Exception e) {
Log.e("initViewPager", "initViewPager", e);
public class TabFragmentPagerAdapter extends FragmentPagerAdapter {
ArrayList&Fragment& mFragmentsL
public TabFragmentPagerAdapter(FragmentManager fm) {
super(fm);
public TabFragmentPagerAdapter(FragmentManager fm, ArrayList&Fragment& fragmentsList) {
super(fm);
mFragmentsList = fragmentsL
public Fragment getItem(int position) {
return mFragmentsList.get(position);
public int getCount() {
return mFragmentsList.size();
public CharSequence getPageTitle(int position) {
return titles.get(position);
public class TabOnClickListener implements View.OnClickListener {
private int index = 0;
public TabOnClickListener(int i) {
public void onClick(View v) {
mVpBody.setCurrentItem(index);
public class MyOnPageChangeListener implements ViewPager.OnPageChangeListener {
public void onPageSelected(int arg0) {
switch (arg0) {
currIndex = arg0;
public void onPageScrolled(int arg0, float arg1, int arg2) {
public void onPageScrollStateChanged(int arg0) {
第四步:编写fragment,这里给出其中一个ActivityFragment.java
package com.figo.study.
import android.animation.A
import android.animation.AnimatorListenerA
import android.animation.ObjectA
import android.annotation.TargetA
import android.content.C
import android.content.I
import android.os.B
import android.os.B
import android.support.annotation.N
import android.support.v7.widget.LinearLayoutM
import android.support.v7.widget.RecyclerV
import android.view.LayoutI
import android.view.V
import android.view.ViewG
import com.figo.study.R;
* Activity
public class ActivityFragment extends android.support.v4.app.Fragment {
public static ActivityFragment newInstance(Context context,Bundle bundle) {
ActivityFragment newFragment = new ActivityFragment();
newFragment.setArguments(bundle);
return newF
private RecyclerView mRecyclerV
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
mRecyclerView =
(RecyclerView) inflater.inflate(R.layout.fragment_activity_new, container, false);
return mRecyclerV
public void onActivityCreated(Bundle savedInstanceState) {
super.onActivityCreated(savedInstanceState);
mRecyclerView.setLayoutManager(new LinearLayoutManager(mRecyclerView.getContext()));
mRecyclerView.setAdapter(new RecyclerViewAdapter(getActivity()));
public class RecyclerViewAdapter extends RecyclerView.Adapter&RecyclerViewAdapter.ViewHolder& {
private Context mC
public RecyclerViewAdapter(Context mContext) {
this.mContext = mC
public RecyclerViewAdapter.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View view =
LayoutInflater.from(parent.getContext()).inflate(R.layout.fragment_activity, parent, false);
return new ViewHolder(view);
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void onBindViewHolder(final RecyclerViewAdapter.ViewHolder holder, int position) {
final View view = holder.mV
public int getItemCount() {
class ViewHolder extends RecyclerView.ViewHolder {
public final View mV
public ViewHolder(View view) {
super(view);
可以看到真正的fragment布局其实是当做recylerview的一项了。
fragment_activity_new.xml布局
&?xml version="1.0" encoding="utf-8"?&
&android.support.v7.widget.RecyclerView
xmlns:android="/apk/res/android"
android:id="@+id/rv_activity"
android:layout_width="match_parent"
android:layout_height="match_parent" /&
fragment_activity.xml布局
&?xml version="1.0" encoding="utf-8"?&
&LinearLayout xmlns:android="/apk/res/android"
android:orientation="vertical" android:layout_width="match_parent"
android:layout_height="match_parent"&
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Activity"
android:id="@+id/textView"
android:layout_gravity="center_horizontal" /&
&/LinearLayout&
注意一点,fragment_activity.xml里面如有listview的话,listitem的布局必须是LinearLayout,而且必须计算listview的高度,不然上下滑动的效果不管用的。
第五步:相关的样式设计style.xml文件
&style name="Theme.DesignDemo" parent="Base.Theme.DesignDemo"&
&style name="Base.Theme.DesignDemo" parent="Theme.AppCompat.Light.NoActionBar"&
&item name="colorPrimary"&#0fb73d&/item&
&item name="colorPrimaryDark"&#0ba823&/item&
&item name="colorAccent"&#FF4081&/item&
&item name="android:windowBackground"&@color/window_background&/item&
第六步:AndroidManifest.xml配置
&?xml version="1.0" encoding="utf-8"?&
&manifest xmlns:android="/apk/res/android"
package="com.figo.study" &
&application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Theme.DesignDemo"&
android:name=".MainActivity"
android:label="@string/app_name" &
&intent-filter&
&action android:name="android.intent.action.MAIN" /&
&category android:name="android.intent.category.LAUNCHER" /&
&/intent-filter&
&/activity&
&/application&
&/manifest&
有了以上6步,相信你也可以打造上下左右都可以有滑动效果的APP了
版权声明:本文为博主原创文章,未经博主允许不得转载。
本页内容版权归属为原作者,如有侵犯您的权益,请通知我们删除。
Xcode7 运行空白模版报错,将AppDelegate中改为 - ( BOOL )application:( UIApplication *)application didFinishLaunchingWithOptions:( NSDictionary *)launchOptions {
return YES ; } 并删除LaunchScreen.storyboard 并在plist中删除
1:语言环境设置: 项目–PROJECT–info–Locailzation 2 : 手动添加项目依赖 Build Settings–Search path–Library Search Paths 加lib依赖 SRCROOT 和 PROJECT_DIR 都值的是 项目配置目录的上一层 好的:模拟器和手机都可以:” ( S R C R O O T ) / B l u e M o b i P r o j e c t / T h i r d P a r t y / B a i d u M a p I O S
我们先假设现在自己创建了个类,我们起名叫MyObject,继承于NSObject。继承知道吧,就是你这个子类(MyObject)如果什么都不写的话,和父类(NSObject)就是一模一样的。OC里几乎所有的类的根源都是NSObject,都是在NSObject的基础上增加成员变量、函数。父类不是你自己写的类,你不敢保证它是安全的,能否成功初始化,你有可能不知道里面是什么样子的。self = [super init],你可能对这步做法可能难以理解。self指向了父类初始化的内存地址。类的初始化函数如果失败会返
效果展示 工程下载地址 · 进入构建结构 首先我们新建一个工程 接下来我们拖进来一个Table View Controller,将Storyboard Entry Point指向我们的Table View Controller。原来的ViewController就可以删除了。效果如图所示 选中Table View Controller,点击上面菜单栏中Editor-Embed in-Navigation Controller 基本的工作我们都做完了,可以讲工程中没用的东西都可以删除了,方便我们进行编写东西
此blog不写API的用法只分析此参数的知识点。 今天学习安卓突然学习到了getinstalledpackages()的方法获取到安装应用信息 ,他接收一个int flags的值,然后在网上查询资料全是 将Int
值 设置为0
即比如 PackageManager manager = context.getPackageManager();// 得到包的管理者 ListPackageInfo installedPackages = manager.getInstalledPackages(0); 本想
应用已经开发出来了,下一步我们需要思考推广方面的工作。那么如何才能让更多的用户知道并使用我们的应用程序呢?在手机----领域,最常见的做法就是将程序发布到某个应用商店中,这样用户就可以通过商店找到我们的应用程序,然后轻松地进行下载和安装。 说到应用商店,在Android领域真的可以称得上是百家争鸣,除了谷歌官方推出的Google Play之外,在国内还有91、豌豆荚、机锋、360等知名应用商店。当然,这些商店所提供的功能都是比较类似的,发布应用的方法也大同小异,因此这里我们就只学习如何将应用发布到Goog
Hello Triangle:OpenGL ES 2.0 版的“Hello world” 本文的文字大部分都是从《OpenGL ES 2.0 编程向导》中摘抄而来,特此说明。 该文是基于OpengGL ES 2.0的,算是本人学习OpenGL的“Hello world”吧。 一个OpengGL ES 2.0程序的实现大致如下所示: 装载顶点和片段着色器。 创建一个项目对象,联系顶点和片段着色器,链接项目。 设置视窗。 清除颜色缓冲区。 最基本的渲染。 准备工作 作为一个“Hello world”类的程序,
题目 来自于: /contest/hiho59/problem/1 时间限制:8000ms 单点时限:1000ms 内存限制:256MB 描述 You are given a txt file, which is performance logs of a single-threaded program. Each line has three columns as follow: [Function Name] [TimeStamp] [Action] [Func
一、Android系统启动 Android框架架构图:(来自网上,我觉得这张图看起来很清晰) Linux内核启动之后就到Android Init进程,进而启动Android相关的服务和应用。 启动的过程如下图所示:(图片来自网上,后面有地址)
Android系统整个过程如下: (一) Init进程的启动 init进程,它是一个由内核启动的用户级进程。内核自行启动(已经被载入内存,开始运行, 并已初始化所有的设备驱动程序和数据结构等)之后,就通过启动一个用户级程序init的方式,完成引导进程。init始
目的: 这篇文章的主要目的是为了让您了解有关于在Unity内如何使用没有刚体的碰撞检测。 在这里,检查的只是垂直运动方向,但可以通过修改脚本,将对象添加到场景检查其他方向 (或更改cube 的位置。 unity就是 3D 的游戏引擎,带有内置物理Nvidia PhysX。游戏对象应用物理模拟必须具有刚体。它常用于碰撞检测。
假设我们只想要碰撞检测模拟物理学,然后只对碰撞检测使用物理引擎可能会降低整体性能。 有两个解决办法: 解决办法-1: 使刚体运动学和捕获
Copyright (C)
ITfish.net

我要回帖

更多关于 获取fragment中的控件 的文章

 

随机推荐