我想设置图标ImageView
,我从这个网站下载图标:FlatIcon
现在我想要设置这个图标的颜色,但使用时setBackground
只需添加背景颜色,而不是设置为图标!
使用时,NavigationView
我可以使用以下代码将颜色设置为图标:app:itemIconTint="@color/colorAccent"
.
如何将颜色设置为图标ImageView
等itemIconTint
?谢谢所有<3
我想TabLayout
在我的应用程序中使用fragment
和ViewPager
.
但我希望禁用点击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) 在我的应用程序中,我想展示一些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)