日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問(wèn) 生活随笔!

生活随笔

當(dāng)前位置: 首頁(yè) > 运维知识 > Android >内容正文

Android

android 动态设置textview的边距,添加边距为动态的Android的TextView(Adding Margins to a dynam...

發(fā)布時(shí)間:2025/3/17 Android 24 豆豆
生活随笔 收集整理的這篇文章主要介紹了 android 动态设置textview的边距,添加边距为动态的Android的TextView(Adding Margins to a dynam... 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

我已經(jīng)通過(guò)這個(gè)以前的答案一堆看,并試圖標(biāo)記為工作的代碼,但到目前為止,我沒有什么可以做說(shuō)服我完全填滿屏幕從左至右創(chuàng)建于runtme TextView的。 我想補(bǔ)充兩側(cè)類似于普通面包的余量。 從那以后,我可以添加陰影的形狀。

我在這里的形式布局。

xmlns:tools="http://schemas.android.com/tools"

android:id="@+id/rel_layout"

android:layout_width="match_parent"

android:layout_height="match_parent" >

android:id="@+id/tv1"

android:layout_width="fill_parent"

android:layout_height="fill_parent"

android:layout_alignParentLeft="true"

android:layout_alignParentTop="true"

android:gravity="center_vertical|center_horizontal"

android:text="@string/hello_world"

android:textColor="@color/holobrightblue"

android:textSize="48sp"

android:textStyle="bold"

tools:context=".MainActivity" />

..和我的代碼

textView = new TextView(m_Context);

RoundRectShape rs = new RoundRectShape(new float[] { 10, 10, 10, 10, 10, 10, 10, 10 }, null, null);

ShapeDrawable sd = new ShapeDrawable(rs);

sd.setAlpha(m_opacity);

textView.setBackgroundDrawable(sd);

textView.setTextColor(m_txtcolor);

textView.setText(toasttitle+"\n"+toastmessage);

textView.setBackgroundColor(Color.BLACK);

textView.setPadding(10,10,10,10);

LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(LayoutParams.MATCH_PARENT,LayoutParams.WRAP_CONTENT);

lp.setMargins(60, 0, 60, 0);

textView.setLayoutParams(lp);

toastView = new Toast(m_Context);

toastView.setView(textView);

toastView.setDuration(m_toastlen);

toastView.setGravity(m_screengravity, 0,0);

toastView.show();

如前所述,沒有什么我已經(jīng)從其他的解決方案試圖似乎填滿所有的臥式空間說(shuō)服TextView的。

我試過(guò)去除形狀等..

有任何想法嗎?

總結(jié)

以上是生活随笔為你收集整理的android 动态设置textview的边距,添加边距为动态的Android的TextView(Adding Margins to a dynam...的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。