Giter VIP home page Giter VIP logo

ui's Introduction

UI

样式效果笔记

显示两行文字,第二行显示半行 ,第二行末尾加上浏览数


//内容所占的大小,屏幕宽减去其他控件占的大小
int contentWidth = ToolsDevice.getWindowPx(mAct).widthPixels - Tools.getDimen(mAct, R.dimen.dp_120);//120=15*2+80+10
String content = map.get("content"); //获取内容
//屏幕第一行能放几个字,
int number = contentWidth / ToolsDevice.sp2px(act, Float.parseFloat(act.getResources().getString(R.dimen.dp_15).replace("dip", "")));
//第二行放一半
int number2 = number + (number / 2);
//如果一行显示不了
if (content.length() >= number) {
	tv_1.setText(content.substring(0, number));
	//如果两行能显示完就不显示后面的省略号
	if (content.length()<= number2 ) {
		tv_2.setText(content.substring(number, content.length()));
	} else {
		tv_2.setText(content.substring(number, number2) + "...");
	}
}else if (content.length() > 0 && content.length() < number) {
	tv_1.setText(content);
}

这样再在第二个TextView后面加个浏览数就可以啦

ui's People

Contributors

ruijiao avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.