簡體   English   中英

Xamarin.Android如何在C#中以編程方式沒有圖像的線性布局和空白區域中添加圖像?

[英]How to add images in a linear layout and empty spaces where there is no images programatically in C#?Xamarin.Android

在此處輸入圖像說明,我要添加一組圖像。 我必須在第一行中放置一個圖像,第二行中的圖像應從第一行圖像的末尾開始

如何在Xamrin android中使用linearlayout實現它?

您是否想像下面的截圖那樣實現它。 在此處輸入圖片說明

如果是這樣,則可以使用linearLayout.SetPaddingRelative(imageView1.Drawable.IntrinsicWidth, 0,0,0); 在以下線性布局中設置填充的開始。

有我的代碼。

 protected override void OnCreate(Bundle savedInstanceState)
    {
        base.OnCreate(savedInstanceState);
        // Set our view from the "main" layout resource
        SetContentView(Resource.Layout.activity_main);
        LinearLayout ll_layout = FindViewById<LinearLayout>(Resource.Id.ll_layout);

        LinearLayout linearLayout1 = new LinearLayout(this);


        ImageView imageView1 = new ImageView(this);
        imageView1.SetImageResource(Resource.Drawable.Capture1);
        linearLayout1.AddView(imageView1);
        ll_layout.AddView(linearLayout1);

        LinearLayout linearLayout2 = new LinearLayout(this);
        linearLayout2.SetPaddingRelative(imageView1.Drawable.IntrinsicWidth, 0,0,0);
        ImageView imageView2 = new ImageView(this);
        imageView2.SetImageResource(Resource.Drawable.Capture2);
        linearLayout2.AddView(imageView2);
        ll_layout.AddView(linearLayout2);



    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM