zoukankan      html  css  js  c++  java
  • 改变shape solid color

    <?xml version="1.0" encoding="utf-8"?>
    <shape xmlns:android="http://schemas.android.com/apk/res/android">
    
        <solid android:color="#FF4081"/>
        <corners android:radius="15dp"/>
    </shape>
    <?xml version="1.0" encoding="utf-8"?>
    <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
        xmlns:tools="http://schemas.android.com/tools"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:paddingBottom="@dimen/activity_vertical_margin"
        android:paddingLeft="@dimen/activity_horizontal_margin"
        android:paddingRight="@dimen/activity_horizontal_margin"
        android:paddingTop="@dimen/activity_vertical_margin"
        tools:context="forezp.com.changesolidcolorfromshape.MainActivity">
    
        <TextView
            android:id="@+id/tv"
            android:background="@drawable/button"
            android:layout_width="wrap_content"
            android:textSize="14sp"
            android:padding="10dp"
            android:textColor="#ffffff"
            android:layout_height="wrap_content"
            android:text="Hello World!" />
    </RelativeLayout>
    
    public class MainActivity extends AppCompatActivity {
        //http://stackoverflow.com/questions/16775891/how-to-change-solid-color-from-the-code
        private TextView tv;
        @Override
        protected void onCreate(Bundle savedInstanceState) {
            super.onCreate(savedInstanceState);
            setContentView(R.layout.activity_main);
            tv=(TextView)findViewById(R.id.tv);
            GradientDrawable myGrad = (GradientDrawable)tv.getBackground();
            myGrad.setColor(Color.BLACK);
        }
    }
  • 相关阅读:
    Scrapy之下载中间件与爬虫中间件
    Scrapy之twisted模块
    Scrapy之下载中间件中的代理中间件HttpProxyMiddleware
    Scrapy之start_urls、爬虫中间件之深度,优先级以及源码流程
    Scrapy之dupefilters(去重)以及源码分析/depth
    NOI 2013 书法家
    NOI2013 快餐店
    NOI2013 树的计数
    NOI2013 UOJ122 向量内积
    NOI2015
  • 原文地址:https://www.cnblogs.com/forezp/p/9852208.html
Copyright © 2011-2022 走看看