小编Bas*_*usa的帖子

无法向“回收者视图”项目添加阴影和边框

我已经创建了recycler viewoffset item decoration并在列表项中添加了并添加了海拔高度属性,但是它不起作用。请帮忙!!

这就是我要的

在此处输入图片说明

是)我有的

在此处输入图片说明

我的抵销商品装饰代码

public class ItemOffsetDecoration extends RecyclerView.ItemDecoration {

private int mItemOffset;

private ItemOffsetDecoration(int itemOffset) {

    mItemOffset = itemOffset;

}

public ItemOffsetDecoration(@NonNull Context context, @DimenRes int itemOffsetId) {

    this(context.getResources().getDimensionPixelSize(itemOffsetId));

}

@Override

public void getItemOffsets(Rect outRect, View view, RecyclerView parent,

                           RecyclerView.State state) {

    super.getItemOffsets(outRect, view, parent, state);

    outRect.set(mItemOffset, mItemOffset, mItemOffset, mItemOffset);

  }

}
Run Code Online (Sandbox Code Playgroud)

这是添加Card View和使用elevation属性后的清单项目。

<?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="wrap_content"
android:clickable="true"
android:focusable="true"
android:longClickable="true"
android:orientation="vertical"
android:paddingBottom="10dp" …
Run Code Online (Sandbox Code Playgroud)

android android-recyclerview

2
推荐指数
1
解决办法
2145
查看次数

如何延迟成员变量的初始化

我有一个这样定义的Java类:

class GlslProgram
{
public:
    class Format {
    public:
        Format& vertex(const char* shader_path);
        std::string m_vertex_shader;

    private:
        std::string load_shader(const char* shader_path);
    };

    void use() const;
    void uniform(const GLchar* name, const GLboolean value) const;


    GlslProgram() {};
    GlslProgram(const Format& format, const bool separable = false);

private:
    GLuint m_handle;
    GLuint compile_shader(const std::string shader_string, const GLenum 
};
Run Code Online (Sandbox Code Playgroud)

第二个构造函数(即,GlslProgram(const Format& format, const bool separable = false);是我唯一想要使用或可用的构造函数。

我想删除默认的构造函数(或使其私有),但是不能这样做,因为我必须GlslProgram在应用程序中声明(未初始化的)实例作为另一个类的成员。

class BasicCubeExample : public Application
{
private:
    virtual void set_info()
    {
        Application::set_info();    
        m_info.title = …
Run Code Online (Sandbox Code Playgroud)

c++

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

标签 统计

android ×1

android-recyclerview ×1

c++ ×1