Skip to content Skip to sidebar Skip to footer

Problem Copying AbsoluteLayout - Com.android.internal.R Cannot Be Resolved

I came to a problem that the only solutions is using a AbsoluteLayout (Just to show something at specific positions). I'm trying to copy the AbsoluteLayout class to avoid it being

Solution 1:

You need to copy over declare-styleable entry from attrs.xml:

<declare-styleable name="AbsoluteLayout_Layout">
    <attr name="layout_x" format="dimension" />
    <attr name="layout_y" format="dimension" />
</declare-styleable>

Just add res/values/attrs.xml file to your application and copy above lines there.


When this is done, update your code to reference R from your package:

import com.your.package.R;
...
public LayoutParams(Context c, AttributeSet attrs) {
    super(c, attrs);
    TypedArray a = c.obtainStyledAttributes(attrs,
            R.styleable.AbsoluteLayout_Layout);
    x = a.getDimensionPixelOffset(
            R.styleable.AbsoluteLayout_Layout_layout_x, 0);
    y = a.getDimensionPixelOffset(
            R.styleable.AbsoluteLayout_Layout_layout_y, 0);
    a.recycle();
}

Post a Comment for "Problem Copying AbsoluteLayout - Com.android.internal.R Cannot Be Resolved"