gpt4 book ai didi

java - 使用 Horizo​​ntalPicker 库的问题

转载 作者:行者123 更新时间:2023-12-01 10:32:10 26 4
gpt4 key购买 nike

enter image description here我实现了this library进入我的应用程序以完成水平选择器 View ,我认为我正确地遵循了它所要求的任何内容,但我不知道为什么它的尼特显示任何内容(小部件在这里,但它完全透明)这就是我实现这一点的方式:

主要 Activity :

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);

FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
fab.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG)
.setAction("Action", null).show();
}
});
}

@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.menu_main, menu);
return true;
}

@Override
public boolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();

//noinspection SimplifiableIfStatement
if (id == R.id.action_settings) {
return true;
}

return super.onOptionsItemSelected(item);
}
}

main.xml:

 <?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
app:layout_behavior="@string/appbar_scrolling_view_behavior"
tools:context="pb.monthpicker.MainActivity"
tools:showIn="@layout/activity_main">



<com.wefika.horizontalpicker.HorizontalPicker
xmlns:picker="http://schemas.android.com/apk/lib/com.wefika.horizontalpicker"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:textColor="@color/colorPrimaryDark"
android:textSize="@dimen/textSize"
android:ellipsize="start"

android:marqueeRepeatLimit="-1"
android:id="@+id/month_picker"
picker:values="@array/values"
picker:dividerSize="@dimen/itemPadding"
picker:sideItems="@integer/sideItems"

android:layout_centerVertical="true"
android:layout_centerHorizontal="true" />

</RelativeLayout>

这是值:

// value of sideItems
`<integer name="sideItems">3</integer>`

// value of text size:
<dimen name="textSize">16dp</dimen>
//value of padding:
<dimen name="itemPadding">8dp</dimen>

// value of array
<string-array name="values">
<item>1</item>
<item>2</item>
<item>3</item>
<item>4</item>
<item>5</item>
<item>6</item>
<item>7</item>
<item>8</item>
<item>9</item>
<item>10</item>
</string-array>

//构建.等级

  apply plugin: 'com.android.application'

android {
compileSdkVersion 23
buildToolsVersion "23.0.2"

defaultConfig {
applicationId "pb.monthpicker"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.wefika:horizontal-picker:+'
}

大家知道我做错了什么吗?任何指导都会对我很有帮助,谢谢:)

最佳答案

替换到你的gradle文件中

compile 'com.wefika:horizontal-picker:+

compile 'com.wefika:horizontal-picker:1.1.0'

尝试使用此布局:

  <?xml version="1.0" encoding="utf-8"?>

<RelativeLayout 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:id="@+id/container"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.wefika.horizontalpicker.example.MainActivity">

<com.wefika.horizontalpicker.HorizontalPicker
android:id="@+id/picker"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@android:color/holo_blue_dark"
android:textSize="22sp"
android:paddingTop="16dp"
android:paddingBottom="16dp"
android:ellipsize="marquee"
android:marqueeRepeatLimit="2"
android:focusable="true"
android:focusableInTouchMode="true"
app:values="@array/values"
app:dividerSize="10dp"
app:sideItems="1"/>
</RelativeLayout>

关于java - 使用 Horizo​​ntalPicker 库的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35033289/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com