相关疑难解决方法(0)

FrameLayout边距不起作用

我的布局结构是这样的

LinearLayout
    FrameLayout
       ImageView
       ImageView
    FrameLayout
    TextView
LinearLayout
Run Code Online (Sandbox Code Playgroud)

我为FrameLayout中的两个ImageView设置了margin.但FrameLayout边距被丢弃,它总是将图像设置为左上角.如果我从FrameLayout更改为LinearLayout,则边距的工作正常.怎么办呢?

<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="horizontal"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:id="@+id/inner1"
    >
        <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
           android:layout_width="wrap_content"
           android:layout_height="wrap_content"
        >

            <ImageView
             android:layout_width="24px" 
             android:layout_height="24px" 
             android:id="@+id/favicon"
             android:layout_marginLeft="50px"
             android:layout_marginTop="50px"
             android:layout_marginBottom="40px"
             android:layout_marginRight="70px"      

            />      
            <ImageView
             android:layout_width="52px" 
             android:layout_height="52px" 
             android:id="@+id/applefavicon" 
             android:layout_marginLeft="100px"
             android:layout_marginTop="100px"
             android:layout_marginBottom="100px"
             android:layout_marginRight="100px"              
            />

        </FrameLayout>  
            <TextView
            android:layout_width="wrap_content" 
            android:layout_height="wrap_content" 
            android:id="@+id/title"                 
            android:layout_marginLeft="10px"        
            android:layout_marginTop="20px"
            android:textColor="#FFFFFF"  
            android:textSize = "15px"
            android:singleLine = "true"
            />

    </LinearLayout>
Run Code Online (Sandbox Code Playgroud)

android android-layout

76
推荐指数
3
解决办法
4万
查看次数

在循环内动态创建ImageView

我编写了这个代码,用于将图像加载到ImageView小部件中:

    protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.gallery);
    i = (ImageView)findViewById(R.id.imageView1);

    new get_image("https://www.google.com/images/srpr/logo4w.png") {
        ImageView imageView1 = new ImageView(GalleryActivity.this);

        ProgressDialog dialog = ProgressDialog.show(GalleryActivity.this, "", "Loading. Please wait...", true);

        protected void onPreExecute(){
             super.onPreExecute();
        }

         protected void onPostExecute(Boolean result) {
             i.setImageBitmap(bitmap); 
         dialog.dismiss();
         }
    }.execute();


}
Run Code Online (Sandbox Code Playgroud)

现在,我想加载几个图像.为此,我需要动态创建图像视图,但我不知道如何...

我想在for循环中运行我的代码:

for(int i;i<range;i++){
   //LOAD SEVERAL IMAGES. READ URL FROM AN ARRAY
}
Run Code Online (Sandbox Code Playgroud)

我的主要问题是动态地在循环内创建几个ImageView

java android imageview

11
推荐指数
1
解决办法
4万
查看次数

动态设置图像视图的边距

我可以知道如何动态设置imageview中的边距吗?

android margins android-imageview

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

如何在MonoDroid的代码隐藏中设置保证金?

这个问题很简单,但我对此一无所知.如何在代码隐藏中将边距设置为窗口小部件.

我在Xamarin的网站上找到了这个文档,但我无法将其用于ImageView

我也在我的ImageView中尝试过Layout()方法,但它没有用.

        ImageView imgView = FindViewById<ImageView>(Resource.Id.imageView);
        imgView.Layout(10, 10, 10, 10);
Run Code Online (Sandbox Code Playgroud)

c# android android-layout xamarin.android xamarin

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