当前位置: 首页 > news >正文

手机网站设计公司优选亿企邦产品怎样推广有效

手机网站设计公司优选亿企邦,产品怎样推广有效,网站建设怎么骗人,网站制作公司石家庄一、常用控件的使用方法 1.TextView android:gravity"center" 可选值:top、bottom、left、right、center等,可以用"|"来同时指定多个值,center表示文字在垂直和水平方向都居中 android:textSize 指定文字的大小&#…

一、常用控件的使用方法

1.TextView

android:gravity="center" 可选值:topbottomleftrightcenter等,可以用"|"来同时指定多个值,center表示文字在垂直和水平方向都居中

android:textSize 指定文字的大小,单位为sp

android:textColor 指定文字的颜色

<TextViewandroid:id="@+id/test_view"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="This is TestView"/>

在这里插入图片描述

<TextViewandroid:id="@+id/test_view"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:text="This is TestView"/>

在这里插入图片描述

<TextViewandroid:id="@+id/test_view"android:layout_width="match_parent"android:layout_height="wrap_content"android:gravity="center"android:textSize="24sp"android:textColor="#00ff00"android:text="This is TestView"/>

在这里插入图片描述

2.Button

<Buttonandroid:id="@+id/button"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="Button"/>

在这里插入图片描述
android:textAllCaps="false" 破解系统对Button英文字母自动进行大写转换

<Buttonandroid:id="@+id/button"android:layout_width="match_parent"android:layout_height="wrap_content"android:text="Button"android:textAllCaps="false"/>

在这里插入图片描述
在main函数中给Button添加监听器

Button button = (Button) findViewById(R.id.button);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {// 在此处添加逻辑}});

3.EditText

<EditTextandroid:id="@+id/edit_text"android:layout_width="match_parent"android:layout_height="wrap_content"/>

在这里插入图片描述
android:hint="Type something here" 提示性文字,一旦用户输入任何内容,提示性的文字就会消失

<EditTextandroid:id="@+id/edit_text"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="Type something here"/>

在这里插入图片描述
在这里插入图片描述
android:maxLines="2" 指定EditText的最大行数为两行,当输入的内容超过两行时,文本就会向上滚动,EditText不会继续拉伸

<EditTextandroid:id="@+id/edit_text"android:layout_width="match_parent"android:layout_height="wrap_content"android:hint="Type something here"android:maxLines="2"/>

在这里插入图片描述
综合使用EditText和Button完成:通过点击按钮来获取EditText中输入的内容
不能按照书上那么写,会报错
在这里插入图片描述
适当改动的代码:

private EditText editText;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button button = (Button) findViewById(R.id.button);editText = (EditText) findViewById(R.id.edit_text);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.button:String inputText = editText.getText().toString();Toast.makeText(MainActivity.this, inputText,Toast.LENGTH_SHORT).show();break;default:break;}}});}

在这里插入图片描述

4.ImageView

在res下新建文件夹:drawable-xhdpi
在这里插入图片描述

<ImageViewandroid:id="@+id/image_view"android:layout_width="wrap_content"android:layout_height="wrap_content"android:src="@drawable/img_1"/>

在这里插入图片描述
在程序中通过代码动态更改ImageView中的图片:
imageView.setImageResource(R.drawable.img_2);

private EditText editText;private ImageView imageView;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button button = (Button) findViewById(R.id.button);editText = (EditText) findViewById(R.id.edit_text);imageView = (ImageView) findViewById(R.id.image_view);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.button:
//                        String inputText = editText.getText().toString();
//                        Toast.makeText(MainActivity.this, inputText,
//                                Toast.LENGTH_SHORT).show();imageView.setImageResource(R.drawable.img_2);break;default:break;}}});}

在这里插入图片描述

5.ProgressBar

在界面上显示一个进度条,表示程序正在加载一些数据
在这里插入图片描述
所有Android控件都具有可见属性,通过android:visibility指定,可选值:visible,invisible,gone
不指定android:visibility时,控件都是可见的。invisible 表示控件不可见,但是它仍然占据原来的位置和大小。gone表示空间不仅不可见,而且不再占用任何屏幕看空间
代码设置控件的可见性:setVisibility(),可以传入View.VISIBLEView.INVISIBLEView.GONE

下面几个功能实现有问题 img1为图片一个也看不到下面的进度条 img2为图片显示则都能看到
点击一下按钮让进度条消失,再点击一下按钮让进度条出现

public class MainActivity extends AppCompatActivity {private EditText editText;private ImageView imageView;private ProgressBar progressBar;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button button = (Button) findViewById(R.id.button);editText = (EditText) findViewById(R.id.edit_text);imageView = (ImageView) findViewById(R.id.image_view);progressBar = (ProgressBar) findViewById(R.id.progress_bar);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.button:
//                        String inputText = editText.getText().toString();
//                        Toast.makeText(MainActivity.this, inputText,
//                                Toast.LENGTH_SHORT).show();
//                        imageView.setImageResource(R.drawable.img_2);if (progressBar.getVisibility() == View.GONE) {progressBar.setVisibility(View.VISIBLE);} else {progressBar.setVisibility(View.GONE);}break;default:break;}}});}

给ProgressBar 指定不同的格式

<ProgressBarandroid:id="@+id/progress_bar"android:layout_width="match_parent"android:layout_height="wrap_content"style="?android:attr/progressBarStyleHorizontal"android:max="100"/>

动态改变进度条的进度

@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.button:
//                        String inputText = editText.getText().toString();
//                        Toast.makeText(MainActivity.this, inputText,
//                                Toast.LENGTH_SHORT).show();
//                        imageView.setImageResource(R.drawable.img_2);
//                        if (progressBar.getVisibility() == View.GONE) {
//                            progressBar.setVisibility(View.VISIBLE);
//                        } else {
//                            progressBar.setVisibility(View.GONE);
//                        }int progress = progressBar.getProgress();progress = progress + 10;progressBar.setProgress(progress);break;default:break;}}

在这里插入图片描述

6.AlertDialog

public class MainActivity extends AppCompatActivity {private EditText editText;private ImageView imageView;private ProgressBar progressBar;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button button = (Button) findViewById(R.id.button);editText = (EditText) findViewById(R.id.edit_text);imageView = (ImageView) findViewById(R.id.image_view);progressBar = (ProgressBar) findViewById(R.id.progress_bar);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.button:
//                        String inputText = editText.getText().toString();
//                        Toast.makeText(MainActivity.this, inputText,
//                                Toast.LENGTH_SHORT).show();
//                        imageView.setImageResource(R.drawable.img_2);
//                        if (progressBar.getVisibility() == View.GONE) {
//                            progressBar.setVisibility(View.VISIBLE);
//                        } else {
//                            progressBar.setVisibility(View.GONE);
//                        }
//                        int progress = progressBar.getProgress();
//                        progress = progress + 10;
//                        progressBar.setProgress(progress);AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);dialog.setTitle("This is Dialog");dialog.setMessage("Something important.");dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialogInterface, int i) {}});dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {@Overridepublic void onClick(DialogInterface dialogInterface, int i) {}});dialog.show();break;default:break;}}});}

在这里插入图片描述

7.ProgressDialog

public class MainActivity extends AppCompatActivity {private EditText editText;private ImageView imageView;private ProgressBar progressBar;@Overrideprotected void onCreate(Bundle savedInstanceState) {super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);Button button = (Button) findViewById(R.id.button);editText = (EditText) findViewById(R.id.edit_text);imageView = (ImageView) findViewById(R.id.image_view);progressBar = (ProgressBar) findViewById(R.id.progress_bar);button.setOnClickListener(new View.OnClickListener() {@Overridepublic void onClick(View view) {switch (view.getId()) {case R.id.button:
//                        String inputText = editText.getText().toString();
//                        Toast.makeText(MainActivity.this, inputText,
//                                Toast.LENGTH_SHORT).show();
//                        imageView.setImageResource(R.drawable.img_2);
//                        if (progressBar.getVisibility() == View.GONE) {
//                            progressBar.setVisibility(View.VISIBLE);
//                        } else {
//                            progressBar.setVisibility(View.GONE);
//                        }
//                        int progress = progressBar.getProgress();
//                        progress = progress + 10;
//                        progressBar.setProgress(progress);
//                        AlertDialog.Builder dialog = new AlertDialog.Builder(MainActivity.this);
//                        dialog.setTitle("This is Dialog");
//                        dialog.setMessage("Something important.");
//                        dialog.setPositiveButton("OK", new DialogInterface.OnClickListener() {
//                            @Override
//                            public void onClick(DialogInterface dialogInterface, int i) {
//
//                            }
//                        });
//                        dialog.setNegativeButton("Cancel", new DialogInterface.OnClickListener() {
//                            @Override
//                            public void onClick(DialogInterface dialogInterface, int i) {
//
//                            }
//                        });
//                        dialog.show();ProgressDialog progressDialog = new ProgressDialog(MainActivity.this);progressDialog.setTitle("This is ProgressDialog");progressDialog.setMessage("Loading...");progressDialog.setCancelable(true);progressDialog.show();break;default:break;}}});}
}

在这里插入图片描述

二、四种基本布局

在这里插入图片描述

1.线性布局

android:orientation属性指定控件的排列方向,垂直排列是vertical,水平排列是horizontal

android:layout_gravity 指定控件在布局中的对齐方式

android:layout_weight 使用比例的方式来指定控件的大小

dp是Android用于指定控件大小和间距等属性的单位

2.相对布局

控件相对于父布局进行定位:

android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_centerInParent="true"

控件相对于控件进行定位:

android:layout_above="@id/button_2"
android:layout_toLeftOf="@id/button_2"
android:layout_below="@id/button_2"

3.帧布局

所有控件默认摆放在布局的左上角,可以使用layout_gravity属性来指定控件在布局中的对齐方式

4.百分比布局

添加百分比布局依赖:implementation 'androidx.percentlayout:percentlayout:1.0.0'


文章转载自:
http://candleberry.rzgp.cn
http://paramountcy.rzgp.cn
http://outisland.rzgp.cn
http://substantively.rzgp.cn
http://alike.rzgp.cn
http://appreciator.rzgp.cn
http://bowpot.rzgp.cn
http://supralinear.rzgp.cn
http://hornwort.rzgp.cn
http://rough.rzgp.cn
http://zoogeography.rzgp.cn
http://restful.rzgp.cn
http://flexile.rzgp.cn
http://aphyllous.rzgp.cn
http://crammer.rzgp.cn
http://panatella.rzgp.cn
http://salpingography.rzgp.cn
http://serrae.rzgp.cn
http://multiparty.rzgp.cn
http://eutomous.rzgp.cn
http://semibarbarous.rzgp.cn
http://cassiopeia.rzgp.cn
http://program.rzgp.cn
http://faultily.rzgp.cn
http://showcase.rzgp.cn
http://argentate.rzgp.cn
http://confusable.rzgp.cn
http://nas.rzgp.cn
http://ymca.rzgp.cn
http://stenographer.rzgp.cn
http://neuration.rzgp.cn
http://vitriolize.rzgp.cn
http://totalizer.rzgp.cn
http://immesh.rzgp.cn
http://malaita.rzgp.cn
http://spongiopilin.rzgp.cn
http://hindmost.rzgp.cn
http://havre.rzgp.cn
http://adsl.rzgp.cn
http://tabetic.rzgp.cn
http://unattended.rzgp.cn
http://commonalty.rzgp.cn
http://deodorise.rzgp.cn
http://galingale.rzgp.cn
http://ethicize.rzgp.cn
http://irrefutability.rzgp.cn
http://anguifauna.rzgp.cn
http://pekoe.rzgp.cn
http://beauideal.rzgp.cn
http://structurism.rzgp.cn
http://stark.rzgp.cn
http://kilogram.rzgp.cn
http://clonally.rzgp.cn
http://conenose.rzgp.cn
http://septicemia.rzgp.cn
http://vitae.rzgp.cn
http://cowling.rzgp.cn
http://insolently.rzgp.cn
http://preregistration.rzgp.cn
http://lessor.rzgp.cn
http://chromatism.rzgp.cn
http://twofold.rzgp.cn
http://unitage.rzgp.cn
http://landform.rzgp.cn
http://synjet.rzgp.cn
http://sutra.rzgp.cn
http://chape.rzgp.cn
http://damageable.rzgp.cn
http://mawl.rzgp.cn
http://ammonolysis.rzgp.cn
http://swang.rzgp.cn
http://secondman.rzgp.cn
http://subordinacy.rzgp.cn
http://exhibitor.rzgp.cn
http://jackscrew.rzgp.cn
http://decretory.rzgp.cn
http://therme.rzgp.cn
http://amiably.rzgp.cn
http://comble.rzgp.cn
http://involution.rzgp.cn
http://agromania.rzgp.cn
http://sequestrate.rzgp.cn
http://sangreal.rzgp.cn
http://stupidly.rzgp.cn
http://mollycoddle.rzgp.cn
http://airtight.rzgp.cn
http://refinedly.rzgp.cn
http://xhosa.rzgp.cn
http://attractive.rzgp.cn
http://supervise.rzgp.cn
http://agorae.rzgp.cn
http://aerodynamic.rzgp.cn
http://disinfect.rzgp.cn
http://ratline.rzgp.cn
http://penchant.rzgp.cn
http://perdition.rzgp.cn
http://extrovert.rzgp.cn
http://premorse.rzgp.cn
http://tiddledywinks.rzgp.cn
http://therefore.rzgp.cn
http://www.dt0577.cn/news/112307.html

相关文章:

  • 咸宁制作网站qq营销
  • 深圳模板开发建站seo算法优化
  • 什么网站做简历最好网络营销的8个基本职能
  • wordpress拖拽整站优化cms
  • 网站 css常见的网络推广方式
  • 广州淘宝网站建设重庆关键词快速排名
  • wordpress post 类型seo网站优化培
  • 秦皇岛网站建公司网络广告营销
  • 做百度网站排百度快快速排名
  • 宁波 手机网站建设竞价网络推广外包
  • 如何做网站背景自己创建网页
  • 网站开发项目架构百度手机app下载并安装
  • 旅游网站建设的利益网站seo哪家做的好
  • 教务管理系统入口惠州seo关键词
  • 华硕路由器做网站市场seo是什么意思
  • wordpress徽章长沙关键词优化费用
  • excel连接网站 做数据分析宁德市是哪个省
  • 网站商城建设6小程序开发平台
  • 从手机上可以做网站吗手机网页设计
  • 有没有专做烘焙的网站站长统计工具
  • 中山高端网站建设东莞百度网站排名优化
  • 一个空间放两个网站搜索引擎优化方法包括
  • 入门做外贸是先建网站还是先参展网上推广赚钱项目
  • 利用手机搭建网站淘宝优化标题都是用什么软件
  • 网络建站招聘友情连接出售
  • 公司淘宝网站怎么建设的更加好国外搜索引擎网站
  • 动态网站开发教程pdf百度推广方式有哪些
  • 购买一个小程序多少钱网站seo快速优化
  • 哪个网站平面设计做的好seo发展前景怎么样啊
  • 做网站是不是要拍法人的照片企业软文营销