小编Olu*_*ide的帖子

浮动动作按钮动画问题

当我运行此问题时,我正在支持设计库中使用fab.我在Android Studio的默认空白活动模板中替换了onCreate方法,这就是它的样子:

import android.os.Bundle;
import android.support.design.widget.FloatingActionButton;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.animation.TranslateAnimation;

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

        final FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab);
        fab.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                TranslateAnimation anim = new TranslateAnimation(0, -500, 0, -500);
                anim.setDuration(1000);
                anim.setFillEnabled(true);
                anim.setFillAfter(true);
                fab.startAnimation(anim);
            }
        });
        fab.setOnLongClickListener(new View.OnLongClickListener() {
            @Override
            public boolean onLongClick(View view) {
                TranslateAnimation anim = new TranslateAnimation(0, -500, 0, -500); …
Run Code Online (Sandbox Code Playgroud)

android android-animation

13
推荐指数
1
解决办法
2650
查看次数

带菜单的Android数据绑定

我正在测试Android内置的新数据绑定功能.我已成功完成对文本视图的简单绑定,甚至双向绑定,并将a绑定List<>到a RecyclerView.现在我想用菜单视图测试它,但是当我将布局XML文件添加到菜单文件夹时,我看到菜单和我添加的项目,但是当我用一个<layout>标签包装该菜单视图的内容时,它说"元素布局必须声明".我没有必要在我测试过的其他布局上做一个特殊的声明.这表明你不能在菜单文件夹中使用布局.是这样的,还是我错过了什么?

data-binding android android-databinding

13
推荐指数
0
解决办法
1669
查看次数

数据绑定:使用多种方法从侦听器绑定单个方法

Android UI Toolkit团队的Yigit Boyar和George Mount成员就数据绑定进行了讨论.在13:41的视频中,乔治山说这个

你也可以做一些奇怪的听众,比如onTextChanged.TextWatcher有三种方法,但每个人都只关心onTextChanged,对吧?如果需要,您实际上只能访问其中一个或全部."

<Button android:onTextChanged="@{handlers.textChanged}" …/>
Run Code Online (Sandbox Code Playgroud)

他似乎在说,而不是使用看起来像这样的通常的addTextChangedListener方法

editText.addTextChangedListener(new TextWatcher() {
    @Override
    public void beforeTextChanged(CharSequence charSequence, int i, int i1, int i2) {}

    @Override
    public void onTextChanged(CharSequence charSequence, int i, int i1, int i2) {
        //Do something
    }

    @Override
    public void afterTextChanged(Editable editable) {}
});
Run Code Online (Sandbox Code Playgroud)

我们可以简单地这样做

<EditText 
    android:onTextChanged="@{handlers::onTextChanged}"
    android:layout_width="match_parent"
    android:layout_height="match_parent"/>
Run Code Online (Sandbox Code Playgroud)

处理程序类

public class Handlers{
    public void onTextChanged(CharSequence s, int start, int before, int count) {
        //Do something
    }
}
Run Code Online (Sandbox Code Playgroud)

代码在这个实例中起作用,但它似乎不适用于监听器有多个方法的其他情况,例如ViewPager的 …

data-binding android android-databinding

10
推荐指数
1
解决办法
2075
查看次数

扩展GridLayout

使用GridLayout,这是一个有效的布局定义.关于'layout_height' attribute should be defined或没有任何警告 'layout_width' attribute should be defined

<GridLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView />
</GridLayout>
Run Code Online (Sandbox Code Playgroud)

另一方面,如果我扩展GridLayout,等效布局会同时给出警告'layout_height' attribute should be defined'layout_width' attribute should be defined

<ExtendedGridLayout
    android:layout_width="match_parent"
    android:layout_height="match_parent">
    <ImageView />
</ExtendedGridLayout>
Run Code Online (Sandbox Code Playgroud)

这就是扩展的gridlayout的样子

package com.github.extendedgridlayout;

import android.annotation.TargetApi;
import android.content.Context;
import android.os.Build;
import android.util.AttributeSet;
import android.widget.GridLayout;

@SuppressWarnings("unused")
public class ExtendedGridLayout extends GridLayout {
    public ExtendedGridLayout(Context context){
        super(context);
    }

    public ExtendedGridLayout(Context context, AttributeSet attrs) {
        super(context, attrs);
    }

    public ExtendedGridLayout(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, …
Run Code Online (Sandbox Code Playgroud)

android android-gridlayout

9
推荐指数
1
解决办法
730
查看次数

如何从源代码构建v4支持库

我正在尝试从源sice构建v4支持库,我修改了库的一部分.我正在尝试使用gradle在ubuntu 13.10上执行此操作.我按照这个答案的说明,但现在我被卡住了.我使用gradle 1.10和ubuntu,因为当我尝试在windows上构建它时,它表示不支持windows,并且在带有gradle 2.4的ubuntu上它表示gradle 1.10是支持的版本.当我尝试建设时

gradle clean jar --stacktrace
Run Code Online (Sandbox Code Playgroud)

我一直得到一个IllegalStateException:llvm-rs-cc丢失了,这是我一直得到的堆栈跟踪的一部分

Caused by: java.lang.IllegalStateException: llvm-rs-cc is missing
    at com.android.builder.AndroidBuilder.compileAllRenderscriptFiles(AndroidBuilder.java:1281)
    at com.android.builder.AndroidBuilder$compileAllRenderscriptFiles.call(Unknown Source)
    at com.android.build.gradle.tasks.RenderscriptCompile.taskAction(RenderscriptCompile.groovy:99)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:63)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.doExecute(AnnotationProcessingTaskFactory.java:219)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:212)
    at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:201)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:533)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:516)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
Run Code Online (Sandbox Code Playgroud)

整个堆栈跟踪就在这里

我尝试在AndroidBuilder.java中查看源代码并且没有任何消息.我甚至尝试将所述llvm-rs-cc文件复制android-sdk-linux/build-tools到尽可能多的文件夹.我已经将llvm-rs-cc二进制文件的路径添加到我的路径中,就像BuildToolInfo.java中的注释一样,以及build-tools, tools, and platform-tools我认为我使用android sdk管理器下载的路径.我确认printenv在重新启动后使用该命令添加了路径.

我究竟做错了什么?

android compilation gradle android-support-library

7
推荐指数
1
解决办法
1395
查看次数