繁体   English   中英

如何通过代码使这张照片动态加权?

[英]How can i make this photos dynamic weight by code?

我希望图片会像我使用此方法3次一样动态,它将给我3张照片,并且重量会动态变化

public void addImageToRaw(final String text, final float rate/*, final TextView textView*/, final PhotosRatingInfo photosRatingInfo)
{
         ImageView imageView = new ImageView(rawLinear1.getContext());
            imageView.setImageBitmap(BitmapFactory.decodeFile(text));
            //imageView.setLayoutParams();
        //PhotosRatingInfo ratingInfo = new PhotosRatingInfo(rate, text);

        rawLinear1.addView(imageView, 150, 150);

        imageView.setOnClickListener(new OnClickListener() {
            @Override
            public void onClick(View view) {
                //MainMenuActivity.Chasttext();

                RateDialog dialog = new RateDialog(text, rate/*, textView*/, photosRatingInfo);
                dialog.show(manager, "");

                //new RateDialog().show(manager, "");

            }
        });
}

一种

实现此目的的替代方法是使用GridView。 这是最好的方法,因为您获得相同的解决方案。

在您的layout.xml中,您可以设置一个权重值。 您只能对一行执行此操作(您可以根据需要创建任意数量的独立行。

<LinearLayout
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:orientation="horizontal"
    android:weightSum="3">

    <ImageView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <ImageView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    <ImageView
        android:layout_width="0dp"
        android:layout_height="wrap_content"
        android:layout_weight="1" />

    </LinearLayout>

否则,如果您确实想要网格,则需要使用GridView,但这需要Android OS 4.3+。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM