我想在我的ViewPager中添加3个底部点,就像这样.

我使用FragmentActivity并支持库ViewPager.
user-interface android android-viewpager viewpagerindicator android-fragmentactivity
我正在尝试使用Jake Wharton的ViewPagerIndicator库,但是我无法在Android Studio中使用我的Gradle项目.
我将其添加为依赖项,如下所示:
dependencies {
// ... other ommitted
compile 'com.viewpagerindicator:library:2.4.1'
compile 'com.android.support:support-v4:19.0.1'
compile 'com.nineoldandroids:library:2.4.0'
// ...
}
Run Code Online (Sandbox Code Playgroud)
但该项目似乎无法识别库中的任何组件.我想知道不同的support-v4版本是否存在依赖性问题,或者是九折机器人的某些东西......?
我试图让Jake Wharton的ViewPagerIndicator与Android Studio合作,但遗憾的是它不起作用.
我从这里下载了.aar文件并将其包含在我的libs文件夹中.
我像这样引用它:
compile files('src/main/libs/viewpagerindicator_2.4.1.aar')
Run Code Online (Sandbox Code Playgroud)
Android Studio给出了以下错误:
Error:duplicate files during packaging of APK
Run Code Online (Sandbox Code Playgroud)
我不熟悉gradle,当它给我这个错误时不知道该怎么办.
你能帮帮我一下吗?
这是我的完整build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "de.xxx"
minSdkVersion 15
targetSdkVersion 19
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:support-v4:20.0.0'
compile 'com.github.amlcurran.showcaseview:library:5.0.0'
compile files('src/main/libs/PdfViewer.jar')
compile files('src/main/libs/viewpagerindicator_2.4.1.aar')
}
Run Code Online (Sandbox Code Playgroud) 我需要在视图分页器文件中获取包含图像的页面指示符.这是我的代码.
public class IndicatorActivity extends Activity {
/** Called when the activity is first created. */
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
MyPagerAdapter adapter = new MyPagerAdapter();
ViewPager myPager = (ViewPager) findViewById(R.id.pager);
myPager.setAdapter(adapter);
myPager.setCurrentItem(0);
TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicat);
indicator.setViewPager( myPager );
}
}
Run Code Online (Sandbox Code Playgroud)
在这段代码中,我得到一个错误 TitlePageIndicator indicator = (TitlePageIndicator)findViewById(R.id.indicat);的TitlePageIndicator cannot be resolved to a type.这是什么错误.我该如何解决?
这是我的xml代码:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="match_parent"
android:layout_height="match_parent"
/>
<com.viewpagerindicator.TitlePageIndicator
android:id="@+id/indicat"
android:layout_height="wrap_content"
android:layout_width="fill_parent" />
</LinearLayout> …Run Code Online (Sandbox Code Playgroud) android activity-indicator android-view android-viewpager viewpagerindicator
我试图让SampleTabsStyled演示从ViewPagerIndicator改变当前选择的标签没有成功文本的颜色.
但是,在标题/选项卡之间切换时,SampleTitlesStyledTheme演示确实会更改其文本颜色.
查看样式xml时:
<resources>
...
<style name="CustomTitlePageIndicator">
<item name="android:background">#18FF0000</item>
<item name="footerColor">#FFAA2222</item>
<item name="footerLineHeight">1dp</item>
<item name="footerIndicatorHeight">3dp</item>
<item name="footerIndicatorStyle">underline</item>
<item name="android:textColor">#AA000000</item>
<item name="selectedColor">#FF000000</item>
<item name="selectedBold">true</item>
</style>
...
<style name="CustomTabPageIndicator" parent="Widget.TabPageIndicator">
<item name="android:background">@drawable/custom_tab_indicator</item>
<item name="android:textAppearance">@style/CustomTabPageIndicator.Text</item>
<item name="android:textColor">#FF555555</item>
<item name="android:textSize">16sp</item>
<item name="android:divider">@drawable/custom_tab_indicator_divider</item>
<item name="android:dividerPadding">10dp</item>
<item name="android:showDividers">middle</item>
<item name="android:paddingLeft">8dp</item>
<item name="android:paddingRight">8dp</item>
<item name="android:fadingEdge">horizontal</item>
<item name="android:fadingEdgeLength">8dp</item>
</style>
<style name="CustomTabPageIndicator.Text" parent="android:TextAppearance.Medium">
<item name="android:typeface">monospace</item>
</style>
...
</resources>
Run Code Online (Sandbox Code Playgroud)
我看到SampleTitlesStyledTheme演示使用了CustomTitlePageIndicator定义selectedColor项目的样式.所以(也许天真)我想补充一下
<item name="selectedColor">#FF000000</item>
Run Code Online (Sandbox Code Playgroud)
对于SampleTabsStyled演示所使用的风格CustomTabPageIndicator …
我想在我的项目中使用viewpageindicator,但导入它时遇到问题.我的XML中有错误.
Missing styles. Is the correct theme chosen for this layout?
Use the Theme combo box above the layout to choose a different layout, or fix the theme style references.
Failed to find style 'vpiCirclePageIndicatorStyle' in current theme
Run Code Online (Sandbox Code Playgroud)
我的XML文件:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<android.support.v4.view.ViewPager
android:id="@+id/pager"
android:layout_width="fill_parent"
android:layout_height="fill_parent" />
<com.viewpagerindicator.CirclePageIndicator
android:id="@+id/indicator"
android:layout_width="248dp"
android:layout_height="30dp"
android:layout_alignParentBottom="true"
android:layout_below="@id/pager"
android:layout_centerHorizontal="true"
android:layout_marginBottom="30dp"
android:padding="3dip" />
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我更新了res/values/styles.xml
<?xml version="1.0" encoding="utf-8"?>
<resources xmlns:android="http://schemas.android.com/apk/res/android">
<style name="hololightnoactionbar" parent="android:Theme.Holo.Light">
<item name="android:windowActionBar">false</item>
<item name="android:windowNoTitle">true</item>
</style>
<style name="dividerstyle" parent="@android:style/Widget.ListView"> …Run Code Online (Sandbox Code Playgroud) 如果我只是告诉你,而不是解释问题,更容易:

正如您所看到的那样,标签标题全部拼接在一起,完全没有样式.它们在通过开关标签滑动时功能正常(尽管除了适当的位置移动之外没有可见的指示)并且点击标签切换视图,但是缺少所有样式.这是代码:
gallerylists.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent" >
<com.viewpagerindicator.TabPageIndicator
android:id="@+id/indicator"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
<android.support.v4.view.ViewPager
android:id="@+id/gallerypager"
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1" />
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
GalleryLists.java
public class GalleryLists extends Activity {
Context context;
private static final String[] titles = new String[] {
"20 Hottest", "20 Worst", "20 Awesomest", "MMA", "Comedy", "Moto", "Games" };
ViewPager listPager;
ListPagerAdapter listPagerAdapter;
PageIndicator indicator;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.gallerylists);
context = this;
listPagerAdapter = new ListPagerAdapter();
ViewPager.OnPageChangeListener changeListener = new ViewPager.OnPageChangeListener() { …Run Code Online (Sandbox Code Playgroud) 我正在使用ViewPageIndicator中的ViewPager,我需要能够在其他人的中间动态插入一个片段.
我试图用FragmentPagerAdapter和FragmentStatePagerAdapter(都来自v4支持代码)管理模型,第一个似乎不管理中间插入页面的任何方式.第二个只有当我做一个天真的getItemPosition实现返回总是POSITION_NONE但这会导致每次刷卡时完全重新创建页面.
我用FragmentStatePagerAdapter(FSP)观察到的问题是这样的:
在代码中查看一下后,似乎提供的fragmentStatePagerAdapter不支持在中间插入.这是正确的还是我错过了什么?
更新: 适配器中的插入是以逻辑方式进行的,当某个编码为真时,页面会增加1.片段创建是使用getItem()中的构造函数以这种方式完成的:
void setCondition(boolean condition) {
this.condition=condition;
notifyDataSetChanged();
}
public int getCount(){
return condition?3:2;
}
public Fragment getItem(int position) {
if(position==0)
return new A();
else if(position==1)
return condition?new C():new B();
else if(position==2 && condition)
return new B();
else throw new RuntimeException("Not expected");
}
public int getItemPosition(Object object) {
if(object instanceof A) return 0;
else if(object instanceof …Run Code Online (Sandbox Code Playgroud) android android-adapter android-viewpager viewpagerindicator
我在平板电脑大小的横向布局上有双窗格,我正在使用片段.
在左边我有一个带有listview的片段.当其中一个项目列表发生单击时,右侧片段将加载详细信息.
在右(细节)片段的布局中有一个com.viewpagerindicator.TabPageIndicator和一个android.support.v4.view.ViewPager.
ViewPager将加载2个元素,每个元素都有它com.viewpagerindicator.TabPageIndicator.我正在尝试突出显示或强调所选标签,但我没有这样做.
我希望你有一些建议:)
android tabcontrol android-layout android-viewpager viewpagerindicator
我有一个RecyclerView包裹在一个LinearLayout,它按预期完美地工作.我可以看到RecyclerView填充的所有数据.到现在为止还挺好.
当我裹LinearLayout在ScrollView,在RecyclerView一片空白.我内心没有看到任何东西RecyclerView.为什么?如何使这项工作.
该页面是a中的一个选项卡ViewPagerIndicator,因此该选项卡中的所有内容都必须位于ScrollView.
谢谢你的帮助.