标签: androiddesignsupport

CollapsingToolbarLayout中的ImageView没有覆盖全高?

我试图实现新的一些问题CollapsingToolbarLayout.滚动,扩展和折叠确实可以正常工作,但是我ImageView(无论我设置的资源类型)都没有覆盖扩展工具栏的整个高度.看这里:

扩大 倒塌

在这里我设置android:src="@color/red"了图像视图,但它从未覆盖真正的工具栏.它也不适用于位图.我在下面发布我的布局.

<android.support.v4.widget.DrawerLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:fitsSystemWindows="true">

    <!-- content -->
    <android.support.design.widget.CoordinatorLayout
        android:fitsSystemWindows="true"
        android:layout_width="match_parent"
        android:layout_height="match_parent">
        <android.support.design.widget.AppBarLayout
            android:layout_height="@dimen/appbar_expanded_height"
            android:layout_width="match_parent"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar"
            android:fitsSystemWindows="true">
            <android.support.design.widget.CollapsingToolbarLayout
                android:layout_height="match_parent"
                android:layout_width="match_parent"
                app:layout_scrollFlags="scroll|exitUntilCollapsed"
                app:expandedTitleMarginStart="48dp"
                app:expandedTitleMarginEnd="64dp"
                app:contentScrim="?attr/colorPrimary"
                android:fitsSystemWindows="true">

                <ImageView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:fitsSystemWindows="true"
                    android:src="@color/red_600"
                    android:scaleType="centerCrop"
                    app:layout_collapseMode="parallax"
                    />
                <android.support.v7.widget.Toolbar
                    android:id="@+id/toolbar"
                    app:layout_collapseMode="pin"
                    android:layout_width="match_parent"
                    android:layout_height="?attr/actionBarSize">
                </android.support.v7.widget.Toolbar>

            </android.support.design.widget.CollapsingToolbarLayout>
        </android.support.design.widget.AppBarLayout>

        <!-- I load fragments here -->
        <FrameLayout
            android:id="@+id/fragment_content"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior"/>
    </android.support.design.widget.CoordinatorLayout>

    <!-- nav drawer -->
    <fragment
        android:layout_width="@dimen/drawer_width"
        android:layout_height="match_parent"
        android:layout_gravity="start"/>
</android.support.v4.widget.DrawerLayout>
Run Code Online (Sandbox Code Playgroud)

在我看来,与奶酪-Chris Banes-app的唯一区别在于,我正在给予app:layout_behavior一个FrameLayout.但是,在该框架内,我加载了具有NestedScrollView作为根视图的片段,这似乎工作正常.

android android-layout android-design-library androiddesignsupport

5
推荐指数
2
解决办法
3963
查看次数

移至Android Design Support v23后,TabLayout样式无法解析@ dimen/tab_max_width

转移到Android Design Support v23.0.0后,Android Studio无法构建一个使用Android Design Support v22.2.1构建的项目:

找不到与给定名称匹配的资源(在'tabMaxWidth'处,值为'@ dimen/tab_max_width').

这是怎么回事?

android android-design-library androiddesignsupport

5
推荐指数
1
解决办法
1660
查看次数

动态更新 Design Support TabLayout 的标题

有没有办法在设计支持 TabLayout 中动态更新选项卡的标题?我尝试在 Adapter 中添加一个方法,该方法更改保存选项卡标题的 ArrayList 的内容并通知适配器,但选项卡标题不会更改为新标题。

适配器:

public class TabAdapter extends FragmentPagerAdapter {
    private final List<Fragment> fragments = new ArrayList<>();
    private final List<String> fragmentTiles = new ArrayList<>();

    public TabAdapter(FragmentManager fm) {
        super(fm);
    }

    public void addFragment(Fragment fragment, String title) {
        fragments.add(fragment);
        fragmentTiles.add(title);
    }

    @Override
    public Fragment getItem(int position) {
        return fragments.get(position);
    }

    @Override
    public int getCount() {
        return fragments.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        return fragmentTiles.get(position);
    }

    public void setFragmentTiles(int index, String title) {
        fragmentTiles.set(index, title);

        Log.e("ARRAY", …
Run Code Online (Sandbox Code Playgroud)

arraylist android-arrayadapter android-design-library androiddesignsupport android-tablayout

5
推荐指数
1
解决办法
3492
查看次数

如何在Android中使用TabItem通过TabLayout

最近谷歌添加android.support.design.widget.TabItemsupportDesign作为文档说:

TabItem是一个特殊的"视图",允许您在布局中声明TabLayout的选项卡项.此视图实际上并未添加到TabLayout,它只是一个虚拟对象,允许设置选项卡项的文本,图标和自定义布局.

但是当我加入TabItems我的时候TabLayout:

 <android.support.design.widget.TabLayout
         android:layout_height="wrap_content"
         android:layout_width="match_parent">

     <android.support.design.widget.TabItem
             android:text="@string/tab_text"/>

     <android.support.design.widget.TabItem
             android:icon="@drawable/ic_android"/>

 </android.support.design.widget.TabLayout>
Run Code Online (Sandbox Code Playgroud)

没有显示任何内容(事实上Tabs的位置存在,但Icon/Text不存在).有没有人知道如何TabItem通过xml 使用?

android material-design androiddesignsupport android-tablayout

5
推荐指数
1
解决办法
5755
查看次数

使用 AppCompat 的设计效果为 Android Button 以编程方式设置 buttonColorNormal

我一直在使用适用于 Android 的 Google 设计支持库。为了设置与应用程序主题不同的按钮的颜色,我在布局 XML 文件中声明按钮如下:

<Button
            style="@style/Widget.AppCompat.Button.Colored"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:theme="@style/MyButton" />
Run Code Online (Sandbox Code Playgroud)

然后将styles.xml中的MyButton定义为

<style name="MyButton" parent="ThemeOverlay.AppCompat">
    <item name="colorButtonNormal">@color/my_color</item>
</style>
Run Code Online (Sandbox Code Playgroud)

根据设计支持库,这给了我一个按钮,背景颜色与@color/my_color我的colors.xml 文件中定义的颜色相同。

因此基本上它是用来android:theme改变colorButtonNormal属性以获得所需的颜色。

我怎样才能以编程方式获得相同的结果?基本上,如果我可以做类似的事情

myButton.setTheme(R.style.MyButton) 
Run Code Online (Sandbox Code Playgroud)

...然后我可以设置colorButtonNormal以获得视图。

我不能设置它喜欢

myButton.setBackgroundColor(ContextCompat.getColor(getContext(),R.color.my_color));
Run Code Online (Sandbox Code Playgroud)

甚至不喜欢

ColorStateList colorStateList = ContextCompat.getColorStateList(getActivity(), R.color.my_color);
ViewCompat.setBackgroundTintList(myButton, colorStateList);
Run Code Online (Sandbox Code Playgroud)

这将移除触摸的设计支持库效果。

android material-design androiddesignsupport

5
推荐指数
1
解决办法
720
查看次数

自24.1设计库以来,SearchView对于collapseActionView参数是不可见的

自从我将Android设计库从23.4.0更新到24.1.1后,我遇到了一个问题

我的SearchView定义如下:

<item android:id="@+id/action_search"
    android:icon="@drawable/ic_search"
    android:title="@string/title_action_search"
    app:actionViewClass="android.support.v7.widget.SearchView"
    app:showAsAction="collapseActionView|ifRoom"
    />
Run Code Online (Sandbox Code Playgroud)

但我的SearchView输入变得不可见(我可以在其中写入,但文本或提示不会出现).

我在下面的图片中描述了3个不同的步骤:

在此输入图像描述

如果我删除"collapseActionView"参数,它工作正常,但searchInput只是屏幕的一半(而不是全宽).

你知道这个库中是否有变化可以解释它吗?

谢谢提前!(抱歉图像质量......)

android android-layout searchview androiddesignsupport

5
推荐指数
0
解决办法
408
查看次数

TextInputLayout :如何为 textinputlayout 的 setError() 设置填充或边距?

我必须在我的工作中使用 Android 设计支持库的 TextInputLayout。我想将 setError() 的文本放在 EditText 下,它位于 TextInputLayout 中。现在太远了,如下图所示。

我在 TextInputLayout 中设置了边距和填充,但两者都不起作用,所以我只设置了 android:layout_marginStart 和 android:layout_marginEnd 就回滚了我的代码。

感谢您的任何建议。

<android.support.design.widget.TextInputLayout
    android:id="@+id/til_et_email"
    android:layout_width="match_parent"
    android:textColorHint="#B32F874E"
    app:errorEnabled="true"
    android:layout_height="wrap_content"
    android:layout_below="@+id/til_et_ID"
    android:layout_alignParentStart="true"
    android:focusableInTouchMode="false"
    android:layout_marginStart="20dp"
    android:layout_marginEnd="20dp" >
    <EditText
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:inputType="textEmailAddress"
        android:hint="Email Address"
        android:ems="12"
        android:textColor="#2F874E"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="50dp"
        android:id="@+id/txtEmail"
        android:layout_marginBottom="50dp" />

</android.support.design.widget.TextInputLayout>
Run Code Online (Sandbox Code Playgroud)

SetError() 与 EditText 字段相距太远

user-interface android androiddesignsupport android-textinputlayout

5
推荐指数
0
解决办法
4162
查看次数

Android 为什么 Facebook SDK 注销按钮不显示?

我开发了一个用facebook登录的应用程序,登录过程没有问题。但是当我想注销时看不到按钮。

损坏的应用截图

坏掉的应用程序

工作应用截图

工作应用程序

损坏的应用程序 gradle 文件;

apply plugin: 'com.android.application'

android {
    compileSdkVersion 24
    buildToolsVersion "24.0.1"
    defaultConfig {
        applicationId "com.ex.ex"
        minSdkVersion 15
        targetSdkVersion 24
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {

    compile fileTree(dir: 'libs', include: ['*.jar'])
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })

    // Glide image library
    compile 'com.android.support:appcompat-v7:24.2.1'
    compile 'com.android.support:design:24.2.1'
    compile 'com.android.support:support-v4:24.2.1'
    compile 'com.github.bumptech.glide:glide:3.7.0'
    compile 'com.google.android.gms:play-services-auth:9.2.1'
    compile 'com.facebook.android:facebook-android-sdk:4.1.0'

    testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'
Run Code Online (Sandbox Code Playgroud)

问题的根源是什么?我怎样才能解决这个问题? …

android facebook android-gradle-plugin androiddesignsupport facebook-sdk-4.x

5
推荐指数
1
解决办法
812
查看次数

如何使用Android设计库中的TabLayout获取当前所选项目位置

我正在使用Android设计库TabLayout,我该如何获得当前所选项目标签位置.

  ViewPager pager = (ViewPager) view.findViewById(R.id.pager);      
  MyPagerAdapter adapter = new MyPagerAdapter(getChildFragmentManager());
  pager.setAdapter(adapter);
  tabLayout.setupWithViewPager(pager);
Run Code Online (Sandbox Code Playgroud)

android android-design-library androiddesignsupport

4
推荐指数
1
解决办法
6470
查看次数

添加Android设计支持库后,Gradle构建速度非常慢

在gradle中添加Android设计支持库后,Android工作室的构建速度非常慢

compile 'com.android.support:design:22.2.0'

但是一旦我移除上面的库就快速构建,30秒对5分钟,我正在使用库中的TabLayout和工具栏因此我需要它,不确定它是库问题还是TabLayout本身需要时间来加载,

有没有办法可以通过任何方式加快构建过程?

更新:实际原因是公司防火墙,虽然设置了代理,但是需要花费大量时间来验证每个传入的文件并导致巨大延迟,因此接受的答案应该有效以避免频繁调用

android gradle android-design-library androiddesignsupport

4
推荐指数
1
解决办法
488
查看次数