English 中文(简体)
相对数值 含有习俗的违约情况 意见
原标题:Scroll a RelativeLayout when it contains custom Views

我试图使一些习俗观念中包含着可发展的相关语言。 这是电影院的计划,它有X,有地方坐标,有宽度和高度(实际上只是直径)。 我只是把它带入这一关系中:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
          android:layout_height="fill_parent"
          android:layout_width="fill_parent"
          android:padding="10px">
<ScrollView
        android:layout_height="wrap_content"
        android:layout_width="fill_parent">
    <RelativeLayout android:id="@+id/scrollable_places"
                    android:layout_height="wrap_content"
                    android:layout_width="wrap_content">
    </RelativeLayout>
</ScrollView>

我这样说:

    RelativeLayout layout = (RelativeLayout) context.findViewById(R.id.scrollable_places);
    RelativeLayout.LayoutParams params = new RelativeLayout.LayoutParams(place.getWidth(),
 place.getHeight());
    params.leftMargin = place.getX();
    params.topMargin = place.getY();
    layout.addView(new Seat(context, place), params);

航海阶级喜欢:

public class Seat extends View {

private Place place;
private boolean isRed = false;

public Seat(Context context, Place place) {
    super(context);
    this.place = place;
    setOnClickListener(new OnSeatClickListener());
}

@Override
protected void onDraw(Canvas canvas) {
    if (!isRed)
        canvas.drawColor(Color.GREEN);
    else
        canvas.drawColor(Color.RED);
}

    protected void setRed() {
        isRed = true;
    }

    private class OnSeatClickListener implements OnClickListener {

        @Override
        public void onClick(View view) {
            ((Seat) view).setRed();
            view.invalidate();
        }
    }
}

意见正在充分拟定。 但是,我有一系列看法,如果其中一些意见没有通过屏幕、滚动式口号进行工作,则屏幕上没有滚动。 你们是否有什么想法,我如何做这种排版?

最佳回答

你们应试着Xml案。 它将对所有装置开展工作。

<ScrollView xmlns:android="http://schemas.android.com/apk/res/android"
    android:fillViewport="true"
    android:padding="10px"
    android:layout_height="fill_parent"
    android:layout_width="fill_parent">
    <RelativeLayout android:id="@+id/scrollable_places"
                android:layout_height="wrap_content"
                android:layout_width="wrap_content">
    </RelativeLayout>
</ScrollView>

感谢。

问题回答

在滚动观点中,你写了<条码>android:layout_hala=“wrap_content”,而不是使用包装——连续五位特定高度,即<条码>android:layout_hal=“100dip”。

Thanks Deepak





相关问题
Spring Properties File

Hi have this j2ee web application developed using spring framework. I have a problem with rendering mnessages in nihongo characters from the properties file. I tried converting the file to ascii using ...

Logging a global ID in multiple components

I have a system which contains multiple applications connected together using JMS and Spring Integration. Messages get sent along a chain of applications. [App A] -> [App B] -> [App C] We set a ...

Java Library Size

If I m given two Java Libraries in Jar format, 1 having no bells and whistles, and the other having lots of them that will mostly go unused.... my question is: How will the larger, mostly unused ...

How to get the Array Class for a given Class in Java?

I have a Class variable that holds a certain type and I need to get a variable that holds the corresponding array class. The best I could come up with is this: Class arrayOfFooClass = java.lang....

SQLite , Derby vs file system

I m working on a Java desktop application that reads and writes from/to different files. I think a better solution would be to replace the file system by a SQLite database. How hard is it to migrate ...

热门标签