我希望我的底部导航栏在按下时(仅在选定区域内)更改背景颜色,就像下面的链接:
http://uupload.ir/files/nq3k_tab_bar.jpg
这是我的选择器的xml:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto">
<item android:state_checked="true" android:color="@color/beyez" />
<item android:state_active="true" app:itemBackground="@color/backbeyez"/>
<item android:color="@color/colorPrimaryDark" />
</selector>
Run Code Online (Sandbox Code Playgroud)
这是活动的xml:
<android.support.design.widget.BottomNavigationView
android:id="@+id/bottomnav"
android:layout_width="382dp"
android:layout_height="52dp"
android:layout_marginBottom="0dp"
app:itemBackground="@color/colorPrimary"
app:itemIconTint="@drawable/nav_items_color"
app:itemTextColor="@drawable/nav_items_color"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:menu="@menu/navigation"
tools:layout_editor_absoluteY="515dp">
</android.support.design.widget.BottomNavigationView>
Run Code Online (Sandbox Code Playgroud)
这是我的Java类的代码:
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
switchorders();
BottomNavigationView bottomNavigationView = (BottomNavigationView)findViewById(R.id.bottomnav);
BottomNavigationViewHelper.disableShiftMode(bottomNavigationView);
bottomNavigationView.setOnNavigationItemSelectedListener(new BottomNavigationView.OnNavigationItemSelectedListener()
{
@Override
public boolean onNavigationItemSelected(@NonNull MenuItem item) {
switch (item.getItemId())
{
case R.id.navigation_orders:
switchorders();
break;
case R.id.navigation_credit:
switchcredits();
break;
case R.id.navigation_works:
switchworks();
break;
case R.id.navigation_profile:
switchprofile();
break;
} …
Run Code Online (Sandbox Code Playgroud) 我们正在尝试创建一个Snackbar。Java应用程序中的代码已使用Android Studio中的Java到Kotlin转换器进行了转换。接下来,我们在许多不同的网站上查看了各种示例,甚至尝试实现《 Kotlin编程指南》一书中的代码。我们将在下面发布所有非工作示例。我们的问题是如何创建适当的语法来显示Snackbar?我们想单击一个带有onClick = onSNACK的btnSNACK以显示Snackbar
这是我们真的要使用的Java到Kotlin的转换器代码
fun onSNACK(view: View){
//Snackbar(view)
//val snackbar = Snackbar(view, "Permission Granted", Snackbar.LENGTH_LONG).setAction("Action", null).show()
snackbar.make(view, "Replace with your own action",
snackbar.LENGTH_LONG).setAction("Action", null).show()
snackbar.setActionTextColor(Color.BLUE)
val snackbarView = snackbar.getView()
snackbarView.setBackgroundColor(Color.LTGRAY)
val textView =
snackbarView.findViewById(android.support.design.R.id.snackbar_text)
textView.setTextColor(Color.BLUE)
textView.setTextSize(28f)
snackbar.show()
}
Run Code Online (Sandbox Code Playgroud)
下次尝试使用此代码
class Snackbar{
object LENGTH_LONG {
}
fun show() {
}
}
fun onSNACK(view: View){
snackbar = Snackbar.make(this, "Welcome to Android Teachers..!!",
Snackbar.LENGTH_LONG)
snackbar.show()
}
Run Code Online (Sandbox Code Playgroud)
我们的布局是具有Snackbar的Activity的RelativeLayout(RL)
class Snackbar(view: View?): Any() {
object LENGTH_SHORT {}
fun View.snack(message: String, length: Int = …
Run Code Online (Sandbox Code Playgroud) 我希望场景中的精灵在相机放大或缩小时不会改变大小.精灵使用不同的画布纹理作为材质.
我发现ParticleBasicMatierial中的sizeAttenuation对我有用.但是如果我使用WenGLRenderer,我必须使用ParticleSystem而不是使用CanvasRenderer的Particle.
我目前使用ParticleSystem只包含一个顶点,每个顶点对应一个ParticleSystem,所以我的场景中有大约800多个ParticleSystem,这可以工作,但是消耗很多.
显然,我不能使用"HUD"作为three.js源代码中的例子,因为精灵都在3D场景中.
有人能帮我吗.或者将sizeAttenuation添加到Sprite材质!谢谢!
这是我最初在build.gradle文件中的内容.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.clans:fab:1.6.1'
compile 'joda-time:joda-time:2.8.2'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.afollestad:material-dialogs:0.7.9.1'
compile 'com.wdullaer:materialdatetimepicker:1.5.3'
compile 'com.android.support:palette-v7:23.0.1'
}
Run Code Online (Sandbox Code Playgroud)
库材料对话框已更新,所以我试图在我的gradle文件中反映相同.图书馆说我应该像这样添加它.
dependencies {
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') {
transitive = true
}
}
Run Code Online (Sandbox Code Playgroud)
所以我尝试了这个,但是当我尝试这个时它拒绝重建项目,并且错误地说"未能解决:com.afollestad.material-dialogs:core:0.8.1.0"
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.android.support:recyclerview-v7:23.0.1'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
compile 'com.github.clans:fab:1.6.1'
compile 'joda-time:joda-time:2.8.2'
compile 'com.android.support:cardview-v7:23.0.1'
compile 'com.wdullaer:materialdatetimepicker:1.5.3'
compile 'com.android.support:palette-v7:23.0.1'
compile('com.afollestad.material-dialogs:core:0.8.1.0@aar') …
Run Code Online (Sandbox Code Playgroud) 我需要在我的应用中实现此组件[材料设计组件] [1]
[1]:http : //i.stack.imgur.com/xaQ03.png只是为了强调,我需要的是文本字段中的下拉列表,而不是操作栏中的下拉列表。
在材料设计组件文档中,这称为“文本字段”下拉列表,https://www.google.com/design/spec/components/menus.html#menus-usage,但我没有找到实现方法,我尝试过很多网站,但是我没有找到类似的东西,你们可以帮我找到一些东西吗?