Flex设定Textinput圆角矩形输入框(转)

本文介绍如何使用Flex为TextInput控件设置特定圆角的聚焦样式。提供了三种方法:通过CheckBox动态更改、直接在MXML中设定及使用样式定义。
[url=http://blog.flexexamples.com/2008/06/12/rounding-specific-corners-on-a-focus-rectangle-in-the-textinput-control-in-flex/](英文)原文地址[/url]


[color=green][b][size=large]1、以下的例子展示如何通过设置focusRoundedCorners来指定被聚焦的TextInput输入控件的矩形输入框的圆角设定。[/size][/b][/color]

<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">

<mx:Script>
<![CDATA[
private function checkBox_change(evt:Event):void {
var corners:Array = [];
if (tLeft.selected) {
corners.push("tl");
}
if (tRight.selected) {
corners.push("tr");
}
if (bLeft.selected) {
corners.push("bl");
}
if (bRight.selected) {
corners.push("br");
}
var str:String = corners.join(" ");
textInput.setStyle("focusRoundedCorners", str);
focusManager.setFocus(textInput);
}
]]>
</mx:Script>

<mx:ApplicationControlBar dock="true">
<mx:Form styleName="plain">
<mx:FormItem label="top left (tl):">
<mx:CheckBox id="tLeft"
selected="true"
change="checkBox_change(event);" />
</mx:FormItem>
<mx:FormItem label="top right (tr):">
<mx:CheckBox id="tRight"
selected="true"
change="checkBox_change(event);" />
</mx:FormItem>
<mx:FormItem label="bottom left (bl):">
<mx:CheckBox id="bLeft"
selected="true"
change="checkBox_change(event);" />
</mx:FormItem>
<mx:FormItem label="top right (br):">
<mx:CheckBox id="bRight"
selected="true"
change="checkBox_change(event);" />
</mx:FormItem>
</mx:Form>
</mx:ApplicationControlBar>

<mx:TextInput id="textInput"
focusThickness="10"
cornerRadius="10" />
<mx:Button/>

</mx:Application>


[img]http://dl.iteye.com/upload/attachment/245859/94590c28-0931-3e9d-9c23-9f94303ad71f.jpg[/img]

[color=green][b][size=large]2、同时也还可以在Mxml设定[/size][/b][/color]

[color=brown]方式1:[/color]


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">

<mx:TextInput id="textInput"
focusThickness="10"
cornerRadius="10"
focusRoundedCorners="tl br" />

</mx:Application>



[color=brown]方式2:[/color]


<?xml version="1.0" encoding="utf-8"?>
<mx:Application xmlns:mx="http://www.adobe.com/2006/mxml"
layout="vertical"
verticalAlign="middle"
backgroundColor="white">

<mx:Style>
TextInput {
focusRoundedCorners: "tl br";
}
</mx:Style>

<mx:TextInput id="textInput"
focusThickness="10"
cornerRadius="10" />

</mx:Application>

<template> <view class="container"> <!-- 顶部固定区域 --> <view class="header-section"> <view class="banner-section"> <image class="banner-image" :src="bannerData.imageUrl" mode="aspectFill" /> </view> <view class="title">{{ bannerData.title }}</view> </view> <!-- 可滚动区域 --> <view class="scroll-container"> <scroll-view scroll-y="true" :enhanced="true" :show-scrollbar="false" class="scroll-view" > <view v-for="item in newsList" :key="item.id" class="news-item" @click="navigateToDetail(item)" > <view class="news-content"> <text class="news-title">{{ item.title }}</text> <text class="news-summary">{{ item.summary }}</text> <text class="news-date">{{ item.publishDate }}</text> </view> <view class="status-box" :class="item.read ? 'read' : 'unread'" > {{ item.read ? '已阅' : '未阅' }} </view> </view> <!-- 加载状态提示 --> <view v-if="loading" class="loading-text">加载中...</view> <view v-if="!loading && newsList.length === 0" class="no-data">暂无数据</view> </scroll-view> </view> <!-- 分页组件 --> <view class="pagination"> <picker class="page-size-picker" :value="pageSizeIndex" :range="pageSizeOptions" range-key="label" @change="changePageSize" > <view>每页 {{ pageSize }} 条</view> </picker> <view class="page-controls"> <button class="page-btn" :disabled="currentPage === 1" @click="goToPage(currentPage - 1)" > 上一页 </button> <view class="page-info"> {{ currentPage }} / {{ totalPages }} </view> <button class="page-btn" :disabled="currentPage >= totalPages" @click="goToPage(currentPage + 1)" > 下一页 </button> </view> <view class="page-jump"> <input type="number" v-model="jumpPage" class="page-input" placeholder="页码" :min="1" :max="totalPages" /> <button class="go-btn" @click="jumpToPage">跳</button> </view> </view> </view> </template> <style scoped> /* 整体容器 - 禁止滚动 */ .container { padding: 30rpx; background-color: #f9f9f9; height: 100vh; /* 使用视口高度 */ overflow: hidden; /* 禁止整个页面滚动 */ box-sizing: border-box; display: flex; flex-direction: column; } /* 顶部固定区域 */ .header-section { flex-shrink: 0; /* 防止顶部区域被压缩 */ } .banner-section { margin-bottom: 20rpx; border-radius: 16rpx; overflow: hidden; box-shadow: 0 4rpx 20rpx rgba(0, 0, 0, 0.1); } .banner-image { width: 100%; height: 320rpx; display: block; } .title { font-size: 36rpx; font-weight: bold; text-align: center; margin-bottom: 30rpx; color: #2c3e50; } /* 滚动区域容器 */ .scroll-container { flex: 1; /* 占据剩余空间 */ min-height: 0; /* 关键:解决flex容器滚动问题 */ display: flex; flex-direction: column; background-color: #fff; border-radius: 16rpx; overflow: hidden; box-shadow: 0 2rpx 10rpx rgba(0, 0, 0, 0.05); } /* 滚动视图 */ .scroll-view { flex: 1; /* 填充父容器 */ height: 100%; /* 确保高度继承 */ } /* 隐藏滚动条 */ .scroll-view ::-webkit-scrollbar { display: none; width: 0; height: 0; color: transparent; } /* 新闻项样式 */ .news-item { padding: 30rpx; display: flex; justify-content: space-between; align-items: flex-start; border-bottom: 1rpx solid #eee; transition: background-color 0.2s; } .news-item:active { background-color: #f5f7fa; } .news-content { flex: 1; padding-right: 20rpx; } .news-title { font-size: 32rpx; font-weight: bold; color: #333; display: block; margin-bottom: 10rpx; } .news-summary { font-size: 28rpx; color: #666; display: block; margin-bottom: 10rpx; line-height: 1.5; } .news-date { font-size: 24rpx; color: #999; display: block; } .status-box { padding: 8rpx 16rpx; font-size: 24rpx; border-radius: 8rpx; min-width: 80rpx; text-align: center; flex-shrink: 0; } .status-box.read { background-color: rgba(76, 175, 80, 0.1); color: #4caf50; } .status-box.unread { background-color: rgba(244, 67, 54, 0.1); color: #f44336; } /* 响应式调整 */ @media (max-height: 600px) { .banner-image { height: 280rpx; } .scroll-container { border-radius: 12rpx; } } /* 分页样式 */ .pagination { display: flex; flex-direction: column; align-items: center; padding: 20rpx 0; background-color: #fff; border-top: 1rpx solid #eee; margin-top: 20rpx; border-radius: 16rpx; box-shadow: 0 -2rpx 10rpx rgba(0, 0, 0, 0.05); } .page-size-picker { background-color: #f5f7fa; padding: 10rpx 30rpx; border-radius: 50rpx; margin-bottom: 20rpx; font-size: 28rpx; } .page-controls { display: flex; align-items: center; justify-content: center; margin-bottom: 20rpx; } .page-btn { margin: 0 20rpx; padding: 10rpx 30rpx; background-color: #4caf50; color: white; border-radius: 8rpx; font-size: 28rpx; line-height: 1.5; } .page-btn:disabled { background-color: #cccccc; color: #999999; } .page-info { min-width: 120rpx; text-align: center; font-size: 28rpx; color: #333; } .page-jump { display: flex; align-items: center; } .page-input { width: 120rpx; height: 60rpx; border: 1rpx solid #ddd; border-radius: 8rpx; padding: 0 20rpx; margin-right: 10rpx; text-align: center; font-size: 28rpx; } .go-btn { padding: 10rpx 30rpx; background-color: #2196f3; color: white; border-radius: 8rpx; font-size: 28rpx; } /* 加载提示 */ .loading-text, .no-data { text-align: center; padding: 40rpx 0; color: #999; font-size: 28rpx; } </style> 这个是我uniapp+vue3项目的一个.vue页面代码,帮我优化一下底部的分页板块,这个板块在手机端看着太大了,我想要缩小这个板块里面的内容并让其在同一行,高度一致
最新发布
08-19
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值