小编Moh*_*uri的帖子

如何在Android中为imageview设置颜色

我想设置图标ImageView,我从这个网站下载图标:FlatIcon
现在我想要设置这个图标的颜色,但使用时setBackground只需添加背景颜色,而不是设置为图标!
使用时,NavigationView我可以使用以下代码将颜色设置为图标:app:itemIconTint="@color/colorAccent".

如何将颜色设置为图标ImageViewitemIconTint?谢谢所有<3

android

47
推荐指数
5
解决办法
7万
查看次数

如何在Android中禁用单击TabLayout

我想TabLayout在我的应用程序中使用fragmentViewPager.
但我希望禁用点击TabLayout以在其间切换fragment,只需滑动即可切换fragmenst.
我写下面的代码,但没有工作,当点击TabLayout项目时,去那fragment!

MainActivity XML:

<android.support.design.widget.CoordinatorLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:app="http://schemas.android.com/apk/res-auto"
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <android.support.design.widget.AppBarLayout
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:theme="@style/ThemeOverlay.AppCompat.Dark.ActionBar">

            <android.support.v7.widget.Toolbar
                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/ThemeOverlay.AppCompat.Light">

                <TextView
                    android:layout_width="match_parent"
                    android:layout_height="match_parent"
                    android:gravity="center"
                    android:text="@string/app_namefull"
                    android:textSize="23sp" />

            </android.support.v7.widget.Toolbar>

            <android.support.design.widget.TabLayout
                android:id="@+id/tabs"
                android:layout_width="match_parent"
                android:layout_height="72dp"
                app:tabGravity="fill"
                app:tabIndicatorColor="@color/white"
                app:tabMode="fixed" />
        </android.support.design.widget.AppBarLayout>

        <android.support.v4.view.ViewPager
            android:id="@+id/viewpager"
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            app:layout_behavior="@string/appbar_scrolling_view_behavior" />

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

MainActivity java:

public class Main_Page extends AppCompatActivity {

    private CollapsingToolbarLayout mCollapsingToolbarLayout;
    private Toolbar toolbar;
    private TabLayout tabLayout; …
Run Code Online (Sandbox Code Playgroud)

android android-fragments

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

如何在 Android 中为 RecyclerView 设置 LayoutManager

在我的应用程序中,我想展示一些RecyclerViews.
我想在一行中显示 3 个项目,我的应用程序应该使用4 个, recyclerView因为recyclerVews每个数据都是其他API

在其中一个中,RecyclerView我可以在一行中显示 3 个 Item,我应该recyclerViews在 this 上方显示另外 3 个RecyclerView

请查看此图片以了解我的意思: 在此处输入图片说明

我用 Java 编写以下代码:

if (movieResponse.getData().getStars().size() > 0) {
                            starsModel.clear();
                            starsModel.addAll(movieResponse.getData().getStars());
                            castAdapter = new CastAdapter(context, starsModel);
                            infoEpisodeFrag_CastRecyclerView.setLayoutManager(new GridLayoutManager(context, 3));
                            infoEpisodeFrag_CastRecyclerView.setHasFixedSize(true);
                            infoEpisodeFrag_CastRecyclerView.setNestedScrollingEnabled(false);
                            infoEpisodeFrag_CastRecyclerView.setAdapter(castAdapter);
                        } else {
                            goneView(infoEpisodeFrag_CastRecyclerView);
                        }
                        //Get Directors
                        if (movieResponse.getData().getDirectors().size() > 0) {
                            directorsModel.clear();
                            directorsModel.add(movieResponse.getData().getDirectors().get(0));
                            directorAdapter = new DirectorAdapter(context, directorsModel);
                            infoEpisodeFrag_DirectorRecyclerView.setLayoutManager(new GridLayoutManager(context, 1));
                            infoEpisodeFrag_DirectorRecyclerView.setHasFixedSize(true);
                            infoEpisodeFrag_DirectorRecyclerView.setNestedScrollingEnabled(false);
                            infoEpisodeFrag_DirectorRecyclerView.setAdapter(directorAdapter);
                        } else { …
Run Code Online (Sandbox Code Playgroud)

android layout-manager android-recyclerview

6
推荐指数
1
解决办法
5088
查看次数